gpt4 book ai didi

github - 通过 API 删除 github 仓库

转载 作者:行者123 更新时间:2023-12-05 03:00:01 24 4
gpt4 key购买 nike

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

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

重现步骤

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

我确保它有范围 delete_repo

enter image description here

然后,为我的 token 创建一个变量导出 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

将 header 更改为 'Authorization: $GITHUB_TOKEN' 给出

{ "message": "Must have admin rights to Repository.",
"documentation_url": "https://developer.github.com/v3/repos/#delete-a-repository" }

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

最佳答案

使用命令(插入用户、 token 和 repo)

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

关于github - 通过 API 删除 github 仓库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57353365/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com