Use token to push some code to GitHub - "Support for password authentication was removed" [duplicate] - github

This question already has answers here:
Message "Support for password authentication was removed. Please use a personal access token instead."
(47 answers)
Closed 1 year ago.
Error message when using git push:
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: unable to access 'https://github.com/codingTheWorld777/react-mini-projects.git/': The requested URL returned error: 403"***
I cannot use my token to access GitHub, so how can I push code to GitHub?

GitHub announced their intent to require the use of token-based authentication for all authenticated Git operations. They will no longer accept account passwords when authenticating Git operations on GitHub.com:
Generate token:
Go to your GitHub account token settings
Generate a token
On Mac:
Go to keychain Access
Press the Login tab and all items
Click GitHub key
Change the password to the recent generated token
On Windows:
Go to Control Panel → User Accounts → Credential Manager
Edit the Generic Credential of GitHub
Paste the token instead of the password

You need to change the remote URL with:
git remote set-url <stream> https://<token>#github.com/<username>/<repo>
token can be found here.

I also encounter this problem today, on macOS.
I solve this problem by:
First, get a token! Follow the guidance of GitHub. I think you can just click the link provided in the warning.
Second, change the key chain on macOS:
Search "Keychain" on macOS.
Search "GitHub".
Change the password in the one that with "Internet Password", using your new token.
Then, my problem is solved and I can "git push" now.

Step 1: Go to your GitHub account → Settings → Developer settings → Personal access tokens → Generate / regenerate your token
Step 2: Go to https://cli.github.com and download GitHub CLI
Step 3: Go to your command line or Terminal → gh auth login and follow with login credentials. Done.

I have the same problem. For me the solution was install the GitHub CLI in https://cli.github.com/. After installing in my OS, I ran gh auth login in my terminal and logged in through the browser with the access token that I generated in the GitHub profile. Follow:
My Account → Settings → Developer settings → Personal access tokens [GENERATE NEW TOKEN]

First of all, you need to create a personal access token in Creating a personal access token
git clone https://github.com/username/repo.git
Username: your_username
Password: your_token

Solution for Mac:
First generate a token from GitHub. And replace your password with the token from the keychain access in the GitHub section.

You need to create a personal access token. You can find the instructions on creating personal access token in Creating a personal access token
Make sure you keep the access token secure & secret. After that you need to replace your current saved password in the device (laptop/desktop) with the access token. In macOS you can search for Keychain and find GitHub with an Internet password and replace it with your access token. For instructions, see Updating credentials from the macOS Keychain.
In Windows, it might be Credential Manager (I'm not sure). Check this out: How to update your Git credentials on Windows

Related

Authentication failed when using Github PAT with Sourcetree

I'm using Sourcetree version 3.4.6.
I have followed the instructions for this SO answer. I get the token and in Tools => Options => Authentication tab I click on the Add text:
I use the PAT as password but I get a "Authentication failed" message.
How can I use PAT with SourceTree?
You should first authenticate with your default browser on your github account with your credentials (or just check if you're already authenticated), then choose in the SourceTree app the "OAuth" authentication instead of the Basic then click "Refresh OAuth token". Now you should be able to enter successfully to your github repos.

GitHub change from password to access token failed

I used the password authentication for GitHub. Today changed. I just removed in PhpStorm the GitHub Account and created a new one with the NEW CREATED ACCESS TOKEN (with full repo access, also private).
I restarted PhpStorm. But if I push or pull I still get the 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.
fatal: unable to access xxxxx
You can try to remove the current PW Git auth from the OS credential store, to make sure it doesn't get used anymore.
In Windows: To open Credential Manager, type credential manager in the search box on the taskbar and select Credential Manager Control panel. Select Web Credentials or Windows Credentials to access the credentials you want to manage.
Mac: Keychain App
Linux: Often libsecret, and can be managed with gnome-keyring/Seahorse/Password app
Find the entries for GitHub.com and delete them.
You may also try to do a git fetch on CLI after that, to make Git prompt you and add the new entry.

Source tree fix for git Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead [duplicate]

This question already has answers here:
Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead [duplicate]
(25 answers)
Closed 1 year ago.
FYI this is specifically for sourcetree
I am having this error when pulling in sourcetree, it was working just fine yesterday but it suddenly had this error.
git -c diff.mnemonicprefix=false -c core.quotepath=false --no-optional-locks fetch origin
remote: Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead.
remote: Please see https://github.blog/2020-07-30-token-authentication-requirements-for-api-and-git-operations/ for more information.
fatal: unable to access 'https://github.com/London-Foster/frontend.git/': The requested URL returned error: 403
I tried having a personal access token and use it on source tree but still was not able to login.
1 - Generate a new token from git dev settings
2 - In SourceTree, you just need to change your repository settings there:
3 - Change the URL/Path with the new format:
https://<USERNAME>:<TOKEN>#<GIT_URL>.git
4 - Press OK and it is good now!
in source tree > open repo settings > remotes tab > edit the remote "URL/path" to be
https://{personal-access-token>#github.com}/{<my-repo>}.git>
then save and try to push
i did like #heratyian answer and works fine.
Step by step using the terminal and github
Remove repo
git remote remove origin
Generate personal access token
https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token
Add remote back using personal access token
Remember to replace <personal-access-token> and <my-repo> with your credentials.
git remote add origin https://<personal-access-token>#github.com/<my-repo>.git>
If on Windows, open the Credentials Manager and delete your github credentials if any.
If on macOS, open the Keychain Access app and delete your github credentials if any.
Then, get a Personal Access Token by following the guide here https://docs.github.com/en/github/authenticating-to-github/keeping-your-account-and-data-secure/creating-a-personal-access-token
Then push your code as normal and when asked enter your newly generated personal access token.
I went:
Tools>Options>Authentication. Edited my account.
I changed Authentication from Basic to OAuth. And now the brownout no longer affects me.
After setting up my PAT and setting up my account in Sourcetree menu -> Preferences -> Accounts, I still got the brownout error.
Adding your account in SourceTree seems to prompt for a password upon opening.
I set up git to cache my credentials:
https://docs.github.com/en/get-started/getting-started-with-git/caching-your-github-credentials-in-git
Then in SourceTree I re-cloned my repo. Got prompted for a password - entered my PAT. Now it's working fine.
I have solved the issue, just to ad up on woland's comment.
First add a personal access token then add it in your credentials
Second add a remote by clicking the gear settings then add a remote
Add the remote of your repository then link it with your account that has logged personal access token.
lastly fetch to that remote origin.

Github 2FA won't let me push to branch

Just added 2FA for Github but now when I go to push changes from the terminal to a branch and I try to authenticate myself with username + password I get rejected because there's nowhere to input my 2FA code...I know my username and password are correct because I can login to the site (with 2FA code). Terminal doesn't provide a space to input that code. How are others working around this?
You'll need a personal access token or SSH key.
The details are here: Accessing GitHub using two-factor authentication - Using two-factor authentication with the command line

How to solve an error while cloning a private repository

I have a repository which is private. Before, I was able to clone it from my terminal by giving the username and password. Few days back I got a mail from GitHub to enable 2FA in my account. I did but now I see my account password doesn't seem to work when I give my password in my terminal. I use Google Authenticator as my TOTP app and I also tried giving that password but still it says authentication failure. Please help me out
You need a "Personal Access Token" (PAT).
In order to generate one, go to your GitHub settings and click on the category called "Developer settings". In that section, go to personal tokens.
There you can generate a new access token (make surer to check repo). When you clone your repository, use this token instead of your password. Now you should be able to clone it.
You can read more about this process here: https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token