13

I am having trouble obtaining and organizing private repos. I am using API V3 with this method: http://share.jjnford.com/HhIZ

I am using the jQuery.getJSON command and passing my OAuth2 access token to the API URL but am only getting public repositories returns.

Also if I fork a private organization repository to a user account (context) and pull the users repositories all the repos (public & private) show up except the private repo forked from an organization.

Can anybody help me out with this... it is my last hurdle...

Thanks in advance!

1
  • The link in the question is no longer working! Commented Jun 6, 2022 at 14:55

2 Answers 2

3

I have found the problem and corrected it. According the the GitHub API V3 there are multiple scopes that can be used. It seems the the "user" scope is not valid anymore. Once I used just the "repo" scope everything was retrieved correctly (private org repos, and private forked org repos).

Sign up to request clarification or add additional context in comments.

1 Comment

The doc you're linking to says 'user' is a valid scope. Do you actually know why your changes worked or are you just guessing that the docs are wrong?
0

I could not find a correct answer for this at the time, and I don't want to ask for the scope "repo" since it's too overkill for my application, it asks for code read/write permssions. Here's what worked for me (I'm using Ruby along with the octokit gem (https://github.com/octokit/octokit.rb)), special thanks to Ivan from the github dev support:

1.- During Oauth, ask for the "read:org" scope and get the Oauth 2 token from Github

2.- initialize octokit's client:

client = Octokit::Client.new(access_token: my_oauth2_token)

3.- Retrieve the user's organizations, we can do it because of the "read:org" scope

organizations = client.organizations

4.- For each organization, retrieve a Github admin Team to which this user belongs. And then, use this Team to retrieve the repos available

organizations.each do |organization|
    admin_team = client.organization_teams(organization[:id]).select { |repo| repo[:permission] == 'admin' }.first
    org_repos << client.team_repositories(admin_team[:id])
end

Yes, you will definitely need more requests to gather all the available repos, but as I said before, In my case, I did not want to ask for the "user" scope.

Note: Yes, the user have to be a member of an "admin" Team within a given Organization to be able to see the private repos.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.