简体   繁体   中英

GitHub API - Get the branches of all repos in a team

We are planning to do a clean up of all the branches in our repos and hence I am trying to get the list of branches for all the repos in our team. I am able to successfully get the repos list using github api but getting a "Bad credentials" error

I got the team Repos using below cmd, and it worked fine:

curl -H "Authorization: token <PERSONALACCESSTOKEN>" -X GET https://api.github.com/teams/:team_id/repos

Tying to get branches in a repo using

curl -H "Authorization: token <PERSONALACCESSTOKEN>" -X GET https://api.github.com/repos/:owner/:repo/branches

I am using same <PERSONALACCESSTOKEN> for the above 2 commands but getting the below error

{ "message": "Bad credentials", "documentation_url": "https://developer.github.com/v3" }

I found the answer, its because I am not the admin. Only admin/owner of repo can list branches. Once I replaced member token with admin's token, it worked.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM