4

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

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

Steps to reproduce

First I created a personal access token here: https://github.com/settings/tokens

I made sure it had the scope delete_repo

enter image description here

Then, create a variable for my token export GITHUB_TOKEN=asasfsafaffafsafafsfs

Finally run this script:

#!/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 

Changing the header to 'Authorization: $GITHUB_TOKEN' gives

{ "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.

2 Answers 2

2

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

curl -u $user:$token -XDELETE "https://api.github.com/repos/$user/$repo" 
Sign up to request clarification or add additional context in comments.

Comments

2

You must generate a token which includes the delete_repo scope through this page: https://github.com/settings/tokens/new

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.