Git Authentication failed. New generated token doesn't work - github

could someone help me to fix this issue?
I'm trying to connect my local repository to GitHub, but I have got this error.
I have tried so many times to solve it without success, following the documentation or generate a new token, as well.
Thanks in advance
Username for 'https://github.com': ...#gmail.com
Password for 'https://...#gmail.com#github.com':
remote: Support for password authentication was removed on August 13, 2021.
remote: Please see https://docs.github.com/en/get-started/getting-started-with-git/about-remote-repositories#cloning-with-https-urls
for information on currently recommended modes of authentication.
fatal: Authentication failed for 'https://github.com/Username/horizontal-gallery.git/'
I would like to access again on my GitHub profile, and work with it.

Make sure the token you are entering as a password when prompted follows the new format:
ghp for GitHub personal access tokens
And make sure you are not creating a "fined-grained" PAT (Personal Access Token), as such token might be too limited in scope and would not work with a specific repository.
Try and create a classic PAT.

Related

Personal Access Token not being accepted/recognised when cloning repo on Mac

Beginner developer here. I created a Personal Access Token (PAT) on Github so that I could clone a repo for local access. When terminal asks for credentials and I enter my PAT I get the error message below, which I interpret as terminal not recognising the token I entered as a PAT (ie terminal thinks I'm entering a standard password)
remote: Support for password authentication was removed on August 13,
2021. Please use a personal access token instead. remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/
for more information. fatal: Authentication failed for
'https://github.com/async-labs/builderbook.git./'
Answers to similar questions posted on Stack Overflow suggest updating keychain access with the PAT. This seems to be successful for many, judging by the upvotes and thankful comments. I've done this but am still getting the same error message.
I've verified the PAT that I'm copying into terminal is the same as the one served up by Github.
There was a suggestion that SAML SSO's may need to go through an additional process but that seems to be for enterprise account and mine is a personal account.
I'm using macOS Big Sur version 11.6
Urghhh. So, just reboot the computer (once you've updated your keychain) and it should work.

Today, github suddenly block me from accessing my repo with my Personal Access Token

Today, Oct 24 2022, at 15:00, I pushed my repo from the dev machine and then pull it on the production one without troubles.
I used my github name and my personal access token: I made a lot of daily commits against several private repo, with no problem until now..
At 17:00, github suddenly stop accessing my push telling me:
Username for 'https://github.com': pdipietro
Password for 'https://pdipietro#github.com':
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
fatal: Authentication failed for 'https://github.com/pdipietro/xxxxxxxx.git/'
I was able to push using VSC, but I'm absolutely unable to pull the repo on the production machine.
I can access www.github.com using my username and password.
I created a new Personal Access Token with all permissions but nothing changed: access is still denied.
Any help will be appreciated.
Well the problem was solved after rebooting all the machines: my dev machines and all the machines hosted on Amazon eheI use Github.
The old personal access token is working again.
I cannot explain but should be interesting to have some ideas on why the problem happened and what the problem exactly is.

Error after I create new GitHub access token

I followed the steps of creating a new token, and then I replace it on my Mac keychain.
After that, I tried to push my code into GitHub, but then got the same error:
Remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
Remote: Please see https://github.blog/2020-12-15-token-authentication-requirements-for-git-operations/ for more information.
Why this error is happening if I created a new token ? What I am missing in this case ?
After Creating the personal token change the origin like this :
git remote set-url origin https://username:<MYTOKEN>#github.com/username/repo.git

After setting up two factor authentication, I get "Repository not found"

After our github has a two factor authentication setup, I can't do pull nor push on command-line due to an error of "repository not found".
C:\myproject>git push origin mybranch
Username for 'https://github.com': myname
Password for 'https://myname#github.com':
remote: Repository not found.
fatal: repository 'https://github.com/myproject.git/' not found
How to resolve this issue?
For folks who are facing the same issue,
Enabling 2FA requires us to use the Personal Access Token(PAT) instead of our password. PAT can be generated from Developer Settings tab. While generating the token make sure to give the necessary permissions(scope) like repo read/write access, etc.,
This worked for me.
Double-check your URL.
It should not be https://github.com/myproject.git/ but https://github.com/myusername/myproject.git/

How to use visual studio code with github and 2FA

Our organisation required us to add 2FA to github. Unfortunately,
now we cant commit our work in visual studio code. VSCode prompts for username and password. It doesnt know about 2FA.
There are some very old posts saying to use a personal access token (PAT), e.g.
https://colinmackay.scot/2015/07/15/two-factor-authentication-with-github-and-visual-studio-2013/comment-page-1/#comment-29984
http://www.anilsezer.com/connecting-github-from-visual-studio-after-twofactor-authentication-enabled
However, this does not work either.
The first article says enter the PAT as the username and leave the password blank in the VSCode github login dialog. This does not work as you cant sumbmit with a blank password. Entering a random password gives
Fatal: HttpRequestException encountered.
An error occurred while sending the request.
fatal: HttpRequestException encountered.
An error occurred while sending the request.
remote: Invalid username or password.
fatal: Authentication failed for 'https://github.com/xxx/xxx.git/'
The second article says to use your user/email as the username, and enter the PAT as the password. This is also what the VSCode documentation says. Tired this too, same problem.
Anyone got this working?
Also, does anyone know which of the "scopes" is required for VSCode? I just ticked "repo". Could this be the problem, are more required?
I would advise you can use Personal access tokens.
Just click on your profile picture on the site https://github.com/ (after login), then on Settings > Personal access tokens > Generate new token. Follow the wizard to select what to grant, at least you'll need repo.
On VS Code you provide your usual user name and for password you provide the newly generated PAT.