Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP 401 while using 'create' action #83

Closed
berinle opened this issue Jun 17, 2011 · 32 comments
Closed

HTTP 401 while using 'create' action #83

berinle opened this issue Jun 17, 2011 · 32 comments

Comments

@berinle
Copy link

berinle commented Jun 17, 2011

I am constantly hitting a HTTP 401 when trying to use

hub create

on my newly created project. Isn't the create action meant to auto create the project on github?

Steps:
~: mkdir -p helloworld
~: cd helloworld
helloworld: echo 'trying out hub gem' > README
helloworld: hub init -g
Initialized empty Git repository in /Users/berinle/helloworld/.git/
helloworld(master) ✗: hub add .
helloworld(master) ✗: hub commit -m "first commit"
[master (root-commit) b770670] first commit
1 files changed, 1 insertions(+), 0 deletions(-)
create mode 100644 README
helloworld(master): hub create
error creating repository: Unauthorized (HTTP 401)
helloworld(master):

Please advice

@mislav
Copy link
Owner

mislav commented Jun 18, 2011

create works for me, so I guess this was either a temporary GitHub issue (known to happen) or your github token is wrong:

git config github.token

@mislav mislav closed this as completed Jun 18, 2011
@berinle
Copy link
Author

berinle commented Jun 18, 2011

Thanks mislav. My token was wrong. It had the old one which has since changed when I updated my pass. Everything works now. Perhaps you folks can make the error message more descriptive. Lovely product!

mislav added a commit that referenced this issue Jun 18, 2011
@nomasprime
Copy link

Excuse my noobishness, where do I get token from? I've tried Personal API Access Tokens from Account > Applications but still getting 401...

@mislav
Copy link
Owner

mislav commented Jul 4, 2013

There is no token anymore. Update hub to the latest version and hub create or other commands that require authentication will ask you for your GitHub username and password and exchange that for an OAuth token which it will store in ~/.config/hub.

@nomasprime
Copy link

Thanks @mislav, thought that might be the case. I have no idea why it's not working for me then, put in my creds several times and still getting 401. I'm using Boxen..

@mislav
Copy link
Owner

mislav commented Jul 5, 2013

What's your hub version? What's the contents of your ~/.config/hub (you should anonymize the OAuth token value if found)? Do you have $GITHUB_USER or $GITHUB_PASSWORD environment variables set by chance?

@nomasprime
Copy link

hub version yields:

git version 1.8.2
hub version 1.10.6

~./config/hub doesn't exist.

Only var set for GitHub is BOXEN_GITHUB_LOGIN.

@mislav
Copy link
Owner

mislav commented Jul 5, 2013

@habitullence So what happens when you do hub create or a similar action? Does it prompt you for your GitHub username and password? Can you paste me the output?

@nomasprime
Copy link

@mislav, here you go:

edna-2:puppet-shunit rick$ hub create habitullence/test
github.com username: habitullence
github.com password for habitullence (never stored): 
Error creating repository: Unauthorized (HTTP 401)

I've tried a bunch of times and checked normal login to Github with same creds.

@ElijahLynn
Copy link

I am having the same issue as the comment above.

@ElijahLynn
Copy link

I think this is related to two factor authentication #399. I will post on that issue instead.

@mislav
Copy link
Owner

mislav commented Sep 18, 2013

@habitullence: did you have 2-factor auth enabled?

@nomasprime
Copy link

@mislav no, should it be?

@mislav
Copy link
Owner

mislav commented Sep 19, 2013

@habitullence You're not obligated to use it, but I was just checking if you have the same issue as @ElijahLynn. It doesn't seem so.

Is the problem maybe that you're passing the repo name wrong? You're doing hub create habitullence/test, but it should be:

hub create test

It will be created under your user by default.

@nomasprime
Copy link

@mislav yep, works great. Thanks

@mislav
Copy link
Owner

mislav commented Sep 19, 2013

So, in this ticket it turned out that @berinle, @habitullence and @ElijahLynn had 3 separate issues that share the same error message. I have to improve error messages in hub in the future and add a debugging flag that users can set to see what's going on.

@wildeyes
Copy link

Hey there, same problem here, using two factor verification, getting a 401 when trying to create -d.

@mislav
Copy link
Owner

mislav commented Oct 28, 2013

@wildeyes Try to upgrade to master version and try again. The latest stable release doesn't support 2FA yet.

brew upgrade hub --HEAD

@wildeyes
Copy link

That's weird, since it asked me for a verfication code. I will upgrade and return here.

@mislav
Copy link
Owner

mislav commented Oct 28, 2013

@wildeyes Oh, then you have the edge version. Not sure why you're getting a 401. I'm going to add debugging features in the new version of hub when I release it.

Are you using regular GitHub.com or using GH Enterprise? Are you trying to create a repo under your account or under an organization?

@wildeyes
Copy link

Using regular GH, Repo under my account.

On Mon, Oct 28, 2013 at 3:33 PM, Mislav Marohnić
[email protected]:

@wildeyes https://github.com/wildeyes Oh, then you have the edge
version. Not sure why you're getting a 401. I'm going to add debugging
features in the new version of hub when I release it.

Are you using regular GitHub.com or using GH Enterprise? Are you trying to
create a repo under your account or under an organization?


Reply to this email directly or view it on GitHubhttps://github.com//issues/83#issuecomment-27222156
.

No Signature.

@matthewgoodwin
Copy link

matthewgoodwin commented Jul 31, 2017

So im getting this error as well.. I have had no problems with hub create until now. now I get:
Error creating repository: Unauthorized (HTTP 401) Bad credentials
I have a very old version of hub, but I do have a ./config/hub file.
I do not have 2FA setup, I have one set of SSH keys and one Personal access token..
I have upgraded to OSSierra and everytime I upgrade my mac, something changes..
Im a noob and I dont have much experience troubleshooting git, so please help..
I have
git version 2.8.4 (Apple Git-73)
hub version 1.12.4

@mislav
Copy link
Owner

mislav commented Jul 31, 2017

@matthewgoodwin It might be that your token stored in ~/.config/hub is outdated. Here's how to fix that:

  1. First upgrade to at least hub 2.2.9 or one of the latest prereleases. You can either use brew install hub or download one of the precompiled binaries from the Releases section.
  2. Unless you have some GitHub Enterprise configuration in your ~/.config/hub file, delete that whole file. That will force re-authentication.
  3. Run hub create again. This will ask you for your GitHub username and your real password. Then it will save a new token in ~/.config/hub and hub should never ask you for the password again.

@matthewgoodwin
Copy link

@mislav Thanks for the timely response! I dont have a Github enterprise config to my knowledge. but I also cant seen whats inside this folder as my zsh is denying permission to access this files content..
zsh: permission denied: .config/hub

@mislav
Copy link
Owner

mislav commented Jul 31, 2017

@matthewgoodwin I can't imagine why you don't have permissions to view files in ~/.config, but it doesn't matter. If that file is the only one in that directory (you can check with sudo ls ~/.config), then simply delete it sudo rm -rf ~/.config and run hub create to reauthenticate.

@matthewgoodwin
Copy link

matthewgoodwin commented Jul 31, 2017

@mislav Im not sure I want to delete the .config dir..
my config directory contains my
git heroku and hub directories..
will this be an issue? should I only remove the hub directory or must I remove the entire .config?

@mislav
Copy link
Owner

mislav commented Jul 31, 2017

If there are other files in there. you can remove just the ~/.config/hub file, of course.

@matthewgoodwin
Copy link

after updating my hub, I actually noticed that I have another heroku dir installed in usr/local while git and hub were also installed in the same directory of my usr/local/Cellar, so I dont think I need anything in the .config dir. Im not certain why I have multiple directories in various places? thanks Ill do some investigating and clean up here!! thanks @mislav

@matthewgoodwin
Copy link

all good here, thanks again @mislav !

@tjddbs0401
Copy link

I have the same problem here.
I have

  • git version 2.25.1
  • hub version 2.14.2
    But everytime I try to create one it shows
$ hub create
github.com username: tjddbs0401
github.com password for tjddbs0401 (never stored): 
Error creating repository: Unauthorized (HTTP 401)
Bad credentials

@mislav

@mislav
Copy link
Owner

mislav commented Mar 17, 2020

@tjddbs0401 I'm sorry, I don't have an idea what could be going wrong there. It seems like you are not entering the right password for your GitHub account. You can try generating and pasting a Personal Access Token instead to see if that helps.

@raelgc
Copy link

raelgc commented Dec 7, 2021

For people coming from Google search: if you just updated your GitHub token, then you need to edit your ~./config/hub file and update the oauth_token value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants