'GitHub authentication failing over https, returning wrong email address
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.
Solution 1:[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:[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:[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:[4]
It may happen in Windows if you stored a different credentials before. Go to Credential Manager and delete stored github credentials
Solution 5:[5]
[Mac only]
If you need to delete your authentication, use
git credential-osxkeychain erase
host=github.com
protocol=https
on Mac.
See https://help.github.com/articles/updating-credentials-from-the-osx-keychain/
Solution 6:[6]
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.
Solution 7:[7]
Just incase this helps anyone else also, I was signed into the mac app, command line working fine, but because I then turned on 2FA, my commands were returning the error. I had to sign out of the app, then I could use my Personal access token in my commands as per ele's answer here.
Hopefully that helps someone!
Solution 8:[8]
- Go to https://github.com/settings/tokens to generate your tokens
- Generate your token and store it safely
- Now try to push your code to github
- Two times you have to give your credentials. First time provide your gmail and password and second time provide your username and the generated token instead of password(at the password field).
- another thing is , if you go to your github profile then you will find your username at the url
It works for me , hoping it will save your time . Best wishes .
Solution 9:[9]
On Windows, you may be silently blocked by your Antivirus or Windows firewall. Temporarily turn off those services and push/pull from remote origin.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | ele |
Solution 2 | |
Solution 3 | Jemil Oyebisi |
Solution 4 | Random |
Solution 5 | Dan Rosenstark |
Solution 6 | palak |
Solution 7 | Community |
Solution 8 | Chayan Roy |
Solution 9 | Vortex |