Search code examples
ruby-on-railsgitgithuboctokit

List all contributors to a private github repository using github api


I know it is possible to do this for a public repository (GET /repos/:owner/:repo/contributors) but I am wondering if there is a way to do this for private repositories that an authenticated user using my app is a member of. Also, I am using octokit.rb gem so any answers in that context are much appreciated.


Solution

  • if there is a way to do this for private repositories that an authenticated user using my app is a member of.

    Create an Octokit client with this authenticated user:

    client = Octokit::Client.new(access_token: authenticated_use.token)
    

    Then get list of collaborators from a repository:

    client.collaborators("octokit/octokit.rb")