通过API删除github仓库 [英] Delete github respository via API

查看:258
本文介绍了通过API删除github仓库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用github API删除存储库列表.但我得到了答复:

I want to delete a list of repositories using the github API. But I get the response:

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

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

复制步骤

首先,我在此处创建了个人访问令牌: https://github.com/settings/tokens

我确保它的作用域为delete_repo

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

Then, create a variable for my token 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存储库}

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

搜索错误并阅读提供的链接对我没有帮助.我如何对自己的存储库(不在组织中)具有管理员权限?我也尝试过在个人访问令牌生成页面中检查一切无效.

Searching the error and reading the provided link does not help me. How can I not have admin rights to my own repository (it's not in an org)? I have also tried checking everything in the personal access token generation page without effect.

推荐答案

使用命令(插入用户,令牌和存储库)

Use the command (plugging in user, token, and repo)

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

这篇关于通过API删除github仓库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆