GitHub authentication failing over https, returning wrong email address
Solution 1
GitHub's support determined the root of the issue right away: Two-factor authorization.
To use GitHub over the shell with https, create an OAuth token. As the page notes, I did have to remove my username and password credentials from Keychain but with osx-keychain
in place, the token is stored as the password and things work exactly as they would over https without two-factor authorization in place.
Solution 2
I do not have an
@github.com
address
You don't have to: the @
is the separator between the username:password and the domain.
It is not an email address.
A full GitHub https url would be:
# 2014:
https://username:[email protected]/username/reponame.git
# 2021+:
https://username:[email protected]/username/reponame.git
Without the token (which would then be asked on the command line), that would give:
https://[email protected]/username/reponame.git
But again, [email protected]
isn't an email address, just the first part of the credentials.
Make sure the case of your username
and reponame
is correct: it is case-sensitive.
Since Aug. 2021, GitHub no longer accept account passwords when authenticating Git operations on GitHub.com.
Only PAT (Personal Access Token)
Note that you can store and encrypt your credentials in:
- 2014: a
.netrc.gpg
(or_netrc.gpg
on Windows) if you don't want to put said credentials in clear in the URL.
See "Is there a way to skip password typing when usinghttps://github
". - 2021+: a credential helper called
manager-core
, using the Microsoft cross-platform GCM (Git Credential Manager)
Solution 3
- Go to Credential Manager => Windows Manager
- Delete everything related to tfs
-
Now click on Add a generic credential and provide the following values
(1) Internet or network adress: git:https://tfs.donamain name (2) username: your username (3) password: your password
this should fix it
Solution 4
It may happen in Windows if you stored a different credentials before. Go to Credential Manager and delete stored github credentials
Solution 5
Same thing happened with me, when i have enabled 2-way authentication for github. Things i did to resolve:
- Get you personal access token. This you have to check and generate if not available already. Link for this: https://github.com/settings/tokens
- Go to your local and delete folder and re-clone branch from github.
- Now try the command you were trying earlier i.e: git pull origin master
- Enter username and In password paste the token generated and also don't forget to save that token somewhere, so you can re-use if required.
Doing this will solve your issue.
ele
Agile software developer with eight years experience across the full stack of web technologies, user interface, testing and debugging, training staff and presenting to stakeholders, with prior experience in content strategy, web writing, and technical support
Updated on June 27, 2020Comments
-
ele almost 4 years
Initiating a push or any other action with GitHub from the command line (over https, not ssh) that calls for the username and password not only fails but, when it does, it returns
Username for 'https://github.com': username Password for 'https://[email protected]': remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/username/repository.git/'
I do not have an
@github.com
address. The password and username are correct.I know I could switch to SSH and use keys but that doesn't answer why the authentication is failing over https.
-
Mark Hildreth over 10 yearsYou can also leave the password out, typing the password every time. In that case it would be
https://[email protected]/username/reponame.git
. -
ele over 10 yearsOh, that make sense. Thank you. I knew about the case sensitivity and I am confident that the username and password I'm providing are correct. (They work fine to sign into the website.)a
-
VonC over 10 years@ele yes, but does your password include special characters (like
! * ' ( ) ; : @ & = + $ , / ? # [ ]
)? They would need to be "percent-encoded" (en.wikipedia.org/wiki/Percent-encoding). -
ele over 10 yearsThe password is alphanumeric. I'll see what 'git remote -v' gives when I'm next at the machine but sounds like I might need to contact GitHub support next.
-
VonC over 10 years@ele try the .netrc approach first (don't even encrypt, just for testing). If that doesn't work, the GitHub support is indeed the next step.
-
VonC over 10 years+1. You also can use a PAT (Personal Access Token) in an encrypted netrc: stackoverflow.com/a/18607931/6309
-
lindhe over 9 yearsWhat is the difference between a PAT and an OAuth?
-
Kerry Jones almost 7 years@lindhe OAuth token is a type of token, a the PAT is an OAauth token in this case.
-
Spenhouet over 5 yearsIt is also possible to directly edit the password in the Windows Credential Manager to the new password.
-
Kellen Stuart over 5 yearswow. I love how it stores the incorrect password if you type it in wrong. Then you have to go manually update it or delete it
-
SliverNinja - MSFT over 4 yearsGood callout - this was happening to me on mac => had to regenerate my PAT
-
Mohd Belal about 4 yearsWe have to generate the token if we need to permissions not present in previous generated tokens. Also if we have lost our previous token, we can generate this new token and use as a password to authenticate instead of our original git password.
-
pabrams almost 3 yearsWhy isn't there a message about this instead of the false authentication error? How the heck would I know this