Question

Per the GitHub API docs, I am requesting the repo scope which gives access to private repositories.

The user is presented with the following dialog, which also mentions private repos. They accept the application.

enter image description here

Despite this, when using the oauth access token obtained when asking for 'repo' access, I can only see public repos when I GET https://api.github.com/users/someusername/repos. No private repos are shown.

The user account is my own, and I have not revoked access.

How can I see private repos using the GitHub API V3?

Was it helpful?

Solution

From testing:

  • GETing /users/someusername/repos doesn't show private repos (even if it's the user whose oauth access token you're using).

  • GETing /user/repos show private repos.

This isn't documented in the GitHub API docs at present, I just found out via testing.

Thanks to @ivanzuzak for suggesting to look at the endpoint.

OTHER TIPS

Screenshot

https://api.github.com/user/repos?access_token=#################################

this url gives all the public and private repositories, To get the token use this

link https://github.com/settings/tokens

Make sure you mark all the ticks given in the scope section

To access private information, you need to include the access_token parameter in the URL . Example:

/users/someusername/repos?access_token=512295a0afb73bdd1c076a00c69f8abcd12345

Access tokens are generated per user. You can generate your personal access token here:

https://github.com/settings/applications

You also need to have permission on the private repository to be able to see information about it. You can also see information about the forks of the private repository that you have access to.

(I'm a newbie with Git and was using the command line following https://developer.github.com/guides/getting-started/ but I had trouble with quoting etc. So I switched to using a browser and made some progress)

In the browser my url is

https://api.github.com/user/repos?access_token=deadbeefdeadbeefdeadbeefdeadbeefdeadbeef

where I have swapped in fake token for my real one (tokens should be treated like passwords are not shared).

This gave me complete list of my private repositories in JSON.

For any Octokit users having this problem: client.list_repos(nil) found here will use GET /user/repos which returns private repos too.

If the other answers don't help - I found that my PAT developer token needs to be authorized within that organization's single sign on.

  1. Pass the pat token in your header (not in the url string)
  2. Go to your tokens https://github.com/settings/tokens
  3. Click the Configure SSO button inline with your token
  4. Authorize your token for the specific organization
  5. You should now see private repos (but be sure to follow the link header for pagination purposes, Github's urls are not uniform)

A picture of the SSO settings described

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top