hub: Unable to authorize with my GitHub password (Unathorized/Not Found)

I already put an alias for hub on my
.bashrc alias git=hub

But when I want to create a repos my credentials always failed

Command attempted: git create jam_hub github.com username: flyingduck92 github.com password for flyingduck92 (never stored):

What happened: Error creating repository: Unauthorized (HTTP 401) Bad credentials. The API can’t be accessed using username/password authentication. Please create a personal access token to access this endpoint: http://github.com/settings/tokens

More info: git version 2.29.1.windows.1 hub version 2.14.2

About this issue

  • Original URL
  • State: open
  • Created 4 years ago
  • Reactions: 14
  • Comments: 42 (3 by maintainers)

Commits related to this issue

Most upvoted comments

I’m sorry for the inconvenience. GitHub deprecated its Authorizations API, which hub relied on for exchanging a password for a token.

Until we fix this in hub, the solution is to generate a Personal Access Token (with at least repo scope) at https://github.com/settings/tokens and paste it instead of the password.

I’m sorry for the inconvenience. GitHub deprecated its Authorizations API, which hub relied on for exchanging a password for a token.

Until we fix this in hub, the solution is to generate a Personal Access Token (with at least repo scope) at https://github.com/settings/tokens and paste it instead of the password.

This information should be in the readme, and not in an issue.

This wasted me some time so I want to write down the solutions. If you have time to switch to gh, do it, otherwise:

  • Generate PAT (with repo scope)

  • Create a ~/.config/hub file like below (per mislav’s comment). Put in your username as user and paste your PAT on oauth_token.

    github.com:
     - user: mislav
       oauth_token: PASTE_YOUR_TOKEN_HERE
       protocol: https
    
  • Try hub clone

I’m sorry for the inconvenience. GitHub deprecated its Authorizations API, which hub relied on for exchanging a password for a token.

Until we fix this in hub, the solution is to generate a Personal Access Token (with at least repo scope) at https://github.com/settings/tokens and paste it instead of the password.

This didn’t fix it for me. Error stays the same. I will try to find a fix.

@mislav Can we change the intimation message until this is fixed? Something like github.com token for <user>: rather than github.com password for <user>: ? I think the message is fairly confusing.

Please, please, please get rid of this tool if it is no longer supported. I just wasted 30 minutes trying to get a previously working setup up and running and ended up here at the bottom of this rabbit hole.

It is fine if the tool needs a token, it is fine if the tool is discontinued, but do your best to surface this to users running the latest version as fast as possible.

If the tool is to continue to be available my suggestions are below.

Not found could be replaced with:

Not found. Are you trying to use a username and password?

Until we fix this in hub, the solution is to generate a Personal Access Token (with at least repo scope) at https://github.com/settings/tokens and paste it instead of the password.

And when it says this:

Error fetching pull requests: Unauthorized (HTTP 401)
Bad credentials

It would be better to say:

Error fetching pull requests: Unauthorized (HTTP 401)
Bad credentials

Try clearing out your ~/.config/hub file. Your next attempt to connect with request that you reauthorize.

I’m sorry for the inconvenience. GitHub deprecated its Authorizations API, which hub relied on for exchanging a password for a token.

Until we fix this in hub, the solution is to generate a Personal Access Token (with at least repo scope) at https://github.com/settings/tokens and paste it instead of the password.

You have NO idea how much I searched the internet to find this solution! THANK YOU!

They really not?

image

Use gh instead of hub, https://github.com/cli/cli

> brew install gh
> gh auth login
> gh repo create 

This wasted me some time so I want to write down the solutions. If you have time to switch to gh, do it, otherwise:

  • Generate PAT (with repo scope)
  • Create a ~/.config/hub file like below (per mislav’s comment). Put in your username as user and paste your PAT on oauth_token.
    github.com:
     - user: mislav
       oauth_token: PASTE_YOUR_TOKEN_HERE
       protocol: https
    
  • Try hub clone

Thanks. This worked.

Somehow the password is not accepting the token I generated. Or is returning a 404.

Why did Git do something that would break a common workflow without first providing a fix for that workflow? Sounds a lot like something Microsoft would do…

Since it doesn’t seem to have been posted here, GitHub added an OAuth flow that doesn’t need a web browser/server: https://docs.github.com/en/developers/apps/authorizing-oauth-apps#device-flow

I just always do SSH as I know how to get it working, however I ended up here as I completely forgot about the token thing, they really need to update the word password to token really.

git:(master) hub create github.com username: blabla github.com password for blabla (never stored): Error creating repository: Not Found (HTTP 404)

Tired using the token too, still got the same error

@pcobos You seem to be using the hub Ruby gem, which last had a release in 2014 and was since rewritten in Go and released through this project’s Releases page. You should upgrade!

I am facing a similar issue, in past whenever i did git push origin master on the new repo using git bash, it prompted me with a username and password screen, where in pwd i used to enter PAT, and things would just work fine. But this time gitbash is not prompting me with username and password.

i created the repo with the below command and the push origin master worked: $ gh repo create

delete ~/.config/hub works to me!

Since it doesn’t seem to have been posted here, GitHub added an OAuth flow that doesn’t need a web browser/server: https://docs.github.com/en/developers/apps/authorizing-oauth-apps#device-flow