Reputation: 51
I'm trying to list the private repositories of a user via the GitHub API. The request I'm currently making to GitHub is the following.
https://api.github.com/users/username/repos?sort=updated&direction=desc&visibility=all
It does return the user's repositories but not the private ones. At first I thought that the problem was with the scopes options on my OAuth token. I currently have the following set in my application.
'user',
'repo',
'repo_deployment',
'admin:repo_hook',
'admin:org_hook',
But even if I set all of the scope option on my dev box, I see all the public repositories but none of the user's private ones. I've also tried removing all of the parameters from the url. So that the request is the following.
https://api.github.com/users/username/repos
Which again did not return the user's private repositories.
I am trying to get the private repositories for the current user. But only the ones owned under their account.
Upvotes: 1
Views: 1793
Reputation: 7484
You are using the wrong endpoint for this. You are after the following endpoint instead:
https://developer.github.com/v3/repos/#list-your-repositories
https://api.github.com/user/repos
List repositories that the authenticated user has explicit permission (:read, :write, or :admin) to access. The authenticated user has explicit permission to access repositories they own, repositories where they are a collaborator, and repositories that they can access through an organization membership.
I've just tested it and this returns your private repositories.
Hope this helps.
Upvotes: 3
Reputation: 5214
You may have to authorize yourself for permission of listing your private repositories.
Get an OAuth Token from the account (or from the OAuth Authorizations API), then add the token as a GET parameter (in query string ?access_token=OAUTH-TOKEN
) or a HTTP header (Authorization: token OAUTH-TOKEN
) of your request, you may have permission for your need.
Upvotes: 0