通过API删除GitHub存储库

4
我想使用Github API 删除一系列的仓库。但是我收到了以下回复:

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

重现步骤

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

我确保它具有 delete_repo 范围。

enter image description here

接下来,创建一个我的令牌变量

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": "必须拥有存储库的管理员权限。",
"documentation_url": "https://developer.github.com/v3/repos/#delete-a-repository" }

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

2
使用以下命令(替换用户、token 和 repo):
curl -u $user:$token -XDELETE "https://api.github.com/repos/$user/$repo"

2

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接