简体   繁体   English

GitHub API-在团队中获取所有存储库的分支

[英]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 我能够使用github API成功获取存储库列表,但收到“错误的凭据”错误

I got the team Repos using below cmd, and it worked fine: 我在下面的cmd中使用了Repos团队,它工作正常:

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 我对以上2条命令使用相同的<PERSONALACCESSTOKEN> ,但收到以下错误

{ "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. 一旦我用admin令牌替换了成员令牌,它就起作用了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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