Getting a user's organization repositories in the GitHub API
We are using the GitHub API on Stack Overflow Careers to bring in a user's repositories. We haven't succeeded in bringing in a user's repositories that are part of an organization.
For example, wycats is a contributor to the jQuery project. Yet querying his repositories via the API does not indicate this -- the jQuery repo is owned by the jQuery organization.
What is the API call(s) to learn that wycats is a co开发者_JAVA技巧ntributor to the jQuery repository? The correct answer will take the form of a URL(s) which returns a list of organization repositories for a given user name. If it takes more than one call, that's fine.
Thanks!
I think this is what you're looking for.
Checking Organization Membership
/user/show/:user/organizations [GET]
https://github.com/api/v2/json/user/show/wycats/organizations
List all public repositories of any organization
/organizations/:org/public_repositories [GET]
https://github.com/api/v2/json/organizations/jquery/public_repositories
you can use github api with authentication. I got errors without retrieving a token first. Here is the working code (just use your own organization and username :-) )
organization="write-here-the-organization"
githubuser="your-github-user"
token=`curl -i -u ${githubuser} -d '{"scopes": ["repo"]}' https://api.github.com/authorizations | grep token | cut -d\" -f 4`
curl -i -H "Authorization: token ${token}" https://api.github.com/orgs/${organization}/repos
as result of the above you will get a long json with all repositories, and their information. you can continue from here.
in my case I wanted only the ssh paths so I will clone all of them in a loop, so I did
curl -i -H "Authorization: token ${token}" https://api.github.com/orgs/${organization}/repos | grep "ssh_url" | cut -d\" -f 4
精彩评论