github - 通过 API 删除 github 仓库

标签 github

我想使用 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/

相关文章:

github - 致命: Could not read from remote repository Laravel Forge

Git 获取单个提交

github - 错误: Undo last git commit on both local and remote

github - 如何在 github 中创建 .md 文件?

json - 如何在 BASH 中检索 JSON 值(git commit 中的自动版本)?

javascript - 可以在网站上嵌入 Github 问题列表(带有特定标签)吗?

github - 查找给定 github 项目发生更改的所有分支

github - GitHub 是否会在一段时间后删除没有事件的存储库?

github - 如何从 GitHub 安装程序?

node.js - 在 package.json 中使用 git 标签(用于 git 依赖项)