【问题标题】:Adding Repos to a team in Github将 Repos 添加到 Github 中的团队
【发布时间】:2019-07-25 09:47:54
【问题描述】:

我在使用 github api 将 Repos 添加到 Github Enterprise 中的团队时遇到问题

根据 GitHub API:我应该调用:

PUT /teams/:team_id/repos/:owner/:repo

我正在使用我的访问令牌进行以下调用

curl -H "Authorization: token personal_access_token" https://api.github.com/teams/test-team/repos/mohit/test_data

我收到了json数据:

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

这里是文档的链接:https://developer.github.com/v3/teams/#add-or-update-team-repository

我无法将 Repos 添加到团队。 如何在 Github Enterprise 中继续将 Repos 添加到组织中的团队?

【问题讨论】:

    标签: curl github


    【解决方案1】:

    执行 curl 命令时,Authorization 标头应如下所示:

    -H "Authorization: token <PERSONALACCESSTOKEN>"

    所以一个完整的 curl put 命令应该是这样的:

    curl -H "Authorization: token <PERSONALACCESSTOKEN>" -X PUT https://api.github.com/teams/<TEAMID>/repos/<ORGANISATION>/<REPO>

    要获取团队 ID,您可以按如下方式列出您的所有组织团队:

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

    如果您是自行托管 GitHub Enterprise,请替换 https://api.github.comhttps://<HOSTNAME>/api/v3/

    进一步阅读:

    API 认证:https://developer.github.com/v3/#authentication

    上市团队:https://developer.github.com/v3/teams/#list-teams

    【讨论】:

    • 很高兴听到它@mohitsehrawat - 也值得stackoverflow.com/help/someone-answers
    • 有没有办法可以传递密码而不是令牌?
    • 如果我们使用单点登录作为登录会怎样?
    • 如果您想通过 curl 使用基本身份验证来与 API 交互,您可以执行以下操作:curl -u "<USERNAME>:<PASSWORD>" -get <APICALL> 据我所知,没有单一登录选项。跨度>
    猜你喜欢
    • 1970-01-01
    • 2020-06-09
    • 2020-09-06
    • 1970-01-01
    • 2017-08-08
    • 2011-04-04
    • 2019-04-11
    • 2023-03-07
    • 2022-01-03
    相关资源
    最近更新 更多