【问题标题】:Delete github respository via API通过 API 删除 github 仓库
【发布时间】:2020-11-12 10:40:13
【问题描述】:

我想使用 github API 删除存储库列表。但我得到了回应:

{ "message": "凭证错误", "documentation_url": "https://developer.github.com/v3" }

重现步骤

首先我在这里创建了一个个人访问令牌:https://github.com/settings/tokens

我确定它有delete_repo的范围

然后,为我的令牌创建一个变量 export GITHUB_TOKEN=asasfsafaffafsafafsfs

最后运行这个脚本:

#!/bin/bash

repos=(
    "my_username/test-1"
)

for i in "${repos[@]}"
do
   :
   curl -XDELETE -H 'Authorization: token $GITHUB_TOKEN' "https://api.github.com/repos/$i ";
done

将标题更改为'Authorization: $GITHUB_TOKEN' 给出

{ "message": "必须拥有 Repository 的管理员权限。",
“documentation_url”: "https://developer.github.com/v3/repos/#delete-a-repository" }

搜索错误并阅读提供的链接对我没有帮助。我怎么能没有我自己的存储库的管理员权限(它不在组织中)?我还尝试在个人访问令牌生成页面中检查所有内容,但没有效果。

【问题讨论】:

    标签: github


    【解决方案1】:

    使用命令(插入用户、令牌和仓库)

    curl -u $user:$token -XDELETE "https://api.github.com/repos/$user/$repo"
    

    【讨论】:

      【解决方案2】:

      您必须通过此页面生成包含 delete_repo 范围的令牌:https://github.com/settings/tokens/new

      【讨论】:

        猜你喜欢
        • 2012-07-03
        • 2015-10-14
        • 1970-01-01
        • 1970-01-01
        • 2021-09-01
        • 2017-07-12
        • 2021-04-03
        • 1970-01-01
        相关资源
        最近更新 更多