How to list organization's private repositories via GitHub API?

Jonik picture Jonik · Jun 6, 2013 · Viewed 31.1k times · Source

I'm trying to get a list of an organization's all repositories, including private ones. (Or to be more specific, all of the private repositories a certain user has access to.)

Reqesting info for the organization (https://api.github.com/orgs/acme?access_token=[...]) shows that there indeed are plenty of private repositories:

...
"public_repos": 5,
"total_private_repos": 68, 
"owned_private_repos": 68, 
...

(The access token I'm using had been previously generated using the API for username/passwd.)

But whatever I try to list the repos...

https://api.github.com/orgs/acme/repos&access_token=[...]   

...GitHub API just returns the 5 public repositories. (Documentation says type=all is default. Also tried adding the parameter type=private; no difference.)

Any idea what I'm doing wrong?

The user to whom the access token was generated in fact has Push & Pull access to just some of the organization's private repositories, but none of those appear in the list I get (just the 5 public repositories).

Answer

Ivan Zuzak picture Ivan Zuzak · Jun 11, 2013

Everything you are doing is OK. However, when creating OAuth tokens for authentication, be sure that you are defining the right scopes. Each scope defines a specific set of permitted actions (information you can read/write), so you should check that you are creating the token with the repo scope.