Jonny
Jonny

Reputation: 1041

"Bad Credentials" when attempting to create a GitHub repo through the CLI using curl

I'm trying to create a GitHub repo using the command line.

It was suggested here that you can use the following command:

curl -u 'USER' https://api.github.com/user/repos -d '{"name":"REPO"}'
# Remember replace USER with your username and REPO with your repository/application name!
git remote add origin [email protected]:USER/REPO.git
git push origin master

When I use it, I'm prompted to enter my password (which I am positive is correct as I can log in successfully on the GitHub.com). I then receive this error:

c:\Development\Projects\MovieStar>curl -u 'jonnymaceachern' https://api.github.com/user/repos -d '{"name":"MovieStar"}'
Enter host password for user ''jonnymaceachern'':
{
  "message": "Bad credentials",
  "documentation_url": "http://developer.github.com/v3"
}

I've tried with no quotes around my username and it just gives me a "Problems parsing JSON" error.

Upvotes: 4

Views: 5562

Answers (2)

Gilles Quénot
Gilles Quénot

Reputation: 185254

What I would do :

 curl -u 'USER:PASWORD' https://api.github.com/user/repos -d '{"name":"REPO"}'

Tested OK on my github account. That way, you will not be prompted to type your password. It that doesn't work, maybe your password is not the good one (or username).

Upvotes: 0

VonC
VonC

Reputation: 1325047

[email protected]:USER/REPO.git is an ssh url, not an https one.
The "password" GitHub is asking you is because ssh doesn't find your public/private keys, and has nothing to do with your GitHub account password.

Use:

git remote add origin https://[email protected]/YourName/REPO.git
git push -u master

Then it will ask you for your http credentials.
If you don't want to enter it for each transaction, see "Is there a way to skip password typing when using https:// github".

Upvotes: 1

Related Questions