Support for password authentication was removed. Please use a personal access token instead
GitGithubGithub ApiGit PullPersonal Access-TokenGit Problem Overview
I got this error on my console when I tried to use git pull
:
> 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 "..." : The requested URL returned error: 403
It's very weird, because I just followed the documentation and created a token two weeks ago on GitHub. The token expires on Tue, Oct 26, 2021. Why has this been removed today?
Git Solutions
Solution 1 - Git
From August 13, 2021, GitHub is no longer accepting account passwords when authenticating Git operations. You need to add a PAT (Personal Access Token) instead, and you can follow the below method to add a PAT on your system.
> ## Create Personal Access Token on GitHub
> From your GitHub account, go to Settings => Developer Settings => Personal Access Token => Generate New Token (Give your password) => Fillup the form => click Generate token => Copy the generated Token, it will be something like ghp_sFhFsSHhTzMDreGRLjmks4Tzuzgthdvfsrta
Now follow below method based on your machine:
> ## For Windows OS ⤴
> Go to Credential Manager from Control Panel => Windows Credentials => find git:https://github.com
=> Edit => On Password replace with with your GitHub Personal Access Token => You are Done
> ##
> If you don’t find git:https://github.com
=> Click on Add a generic credential => Internet address will be git:https://github.com
and you need to type in your username and password will be your GitHub Personal Access Token => Click Ok and you are done
> ## For macOS ⤴
> Click on the Spotlight icon (magnifying glass) on the right side of the menu bar. Type Keychain access then press the Enter key to launch the app => In Keychain Access, search for github.com
=> Find the internet password entry for github.com
=> Edit or delete the entry accordingly => You are done
> ## For a Linux-based OS ⤴
> For Linux, you need to configure the local GIT client with a username
> and email address,
>
> $ git config --global user.name "your_github_username"
> $ git config --global user.email "your_github_email"
> $ git config -l
>
> Once GIT is configured, we can begin using it to access GitHub.
> Example:
>
> $ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY
> > Cloning into YOUR-REPOSITORY
...
> Username: -v
to verify
>
> $ git pull -v
> Linux/Debian
>(Clone as follows):
>
> git clone https://
> ## For PhpStorm
> If you are using PhpStorm, go to menu Git => pull and select authentication via Personal Access Token. Enter your PAT
it will allow you to pull/push the changes.
Solution 2 - Git
If you're using macOS, just simply follow these steps:
- Go to this link: https://github.com/settings/tokens (Profile -> settings -> developers setting -> personal access tokens). (don't go to repository setting; it's your profile setting)
- Generate a new token and copy-paste it somewhere safely.
- Now search for an app in your Mac, named
Keychain Access
. - Search for
github.com
(if there are multiple GitHub logins then chooseKind: Internet password
), double-click it. - Click on show password, then enter your Mac's password and hit Enter.
- Password should be visible by now. Now, just paste the token you generated in step 2 and click Save changes.
And that's it. Enjoy!
If you're using Windows:
- Follow steps 1 and 2 as above.
- Search for an application in your Windows OS, named Credential Manager → then Windows Credentials.
- Search for
github.com
and edit the password with thetoken
you have generated on GitHub. Now enjoy!
Developer's hack (shortcode):
git remote set-url origin https://<githubtoken>@github.com/<username>/<repositoryname>.git
While cloning:
git clone https://<username>:<githubtoken>@github.com/<username>/<repositoryname>.git
It will work on every OS (Mac, Windows, or Linux).
Cons: You have to remember or should need to do to each repository in your local. So I'll prefer everyone to use above mentioned steps.
NOTE:
For those who don't have this entry: it could be made. one way to do it is- to clone a project. then it will ask for your username and password. instead of password give it the token and then the entry would be made.
Solution 3 - Git
Use My Account → Settings → Developer settings → Personal access tokens → Generate new token.
git remote set-url origin https://<token>@github.com/<username>/<repo>
Solution 4 - Git
For Linux these simple steps can solve your problem
-
If your Git password is cached in credential.helper, then unset it:
git config --local --unset credential.helper
Or, If you have set your credentials globally, then:
git config --global --unset credential.helper
-
Now go to your GitHub Account settings
-
Click Developer Settings
-
Select Personal Access
-
Generate a token with the given permissions, e.g.,
-
Now
git pull
inside your Git repository -
Provide a username and the generated token as a password
That is a straightforward solution step by step.
PS: If you are annoyed by Git asking for username/token again and again, follow these three simple steps
-
Run
nano ~/.git-credentials
. Remove the GitHub line and save it. -
git config --global credential.helper store
Risky as physically the token is saved in file
~/.git-credentials
-
Run
git pull
and provide the username and password only once
It will not ask for the username and access token again and again now!
Solution 5 - Git
GitHub has made changes in password authentication. If you are trying to access git by username and password then it does not allow you. So use a personal access token instead of a password to access git every where.
Here are the steps to generate Personal access tokens.
Click here - https://github.com/settings/tokens
Step 1 - Open GitHub and log in with your credentials.
Step 2 - Click on the Setting menu.
Step 3 - From the Setting menu click on Developer Settings
Step 4 - From the Developer Settings, menu click on Personal access token
Step 5 - From the Personal access token click on the Generate new Token button.
Step 6 - Now fill up required details like Note, Expiration, Select scopes. And then click on Generate Token button.
Step 7 - After that new token has been generated. Copy that generated token and use this token to access Git with username and token.
If you are using windows operating system then please follow the below step.
Open Control Panel => User Accounts => Manage your credentials => Windows Credentials.
It will show all generic credentials. Find your GitHub URL and click on that. Now click on the edit button. And then add the personal access token generated from GitHub into the password field. And click on the Save button.
Now you can access git.
If you are accessing Git in Android Studio, if asked for a password then add the GitHub personal access token instead of your password every where.
Solution 6 - Git
This message means that you're using a password instead of a personal access token to access GitHub over HTTPS, and that's no longer allowed. GitHub has disabled password authentication because it's common for people to accidentally leak their passwords, and while a personal access token can be restricted to limit the damage, a password cannot.
If you haven't explicitly entered your password at a prompt, then it's likely you have a credential manager which is saving your password and sending it without prompting you.
You can follow the directions for clearing your credential manager listed in the Git FAQ:
$ echo url=https://[email protected] | git credential reject
You should use this same URL, but replace account
with your own username (e.g., in my case, it would look like echo url=https://[email protected]
).
Then, the next time you try to push or pull, Git will prompt you for a username and password. For the username, enter your GitHub username, and for the password, generate a new personal access token on the appropriate settings page and paste it into the password field. If you're working from the command line, you may not see any indication that the password was successfully pasted; this is normal, so just hit Enter afterwards.
That will save the personal access token in your credential manager for the next time, assuming you have one set up. If you're not sure if you have one set up, run git config credential.helper
and see if it outputs anything.
If you don't have one set up, you should add one so that you don't have to memorize your token. Run one of the following commands, depending on operating system:
git config --global credential.helper manager
on Windows;git config --global credential.helper osxkeychain
on macOS;git config --global credential.helper libsecret
on Linux (if available); orgit config --global credential.helper store
on Linux iflibsecret
isn't available.
Then you can try the push or pull again until you're no longer prompted.
Solution 7 - Git
Generate an access token in GitHub from Settings → Developer settings.
If you have cloned your repository in the past and made it as origin, then you can change the authentication so,
git remote set-url origin https://<token>@github.com/<username>/<repo>.git
If you are going to clone repository after 13 August 2021, then you can use the normal clone command and set the generated access token in the password field.
Solution 8 - Git
For Ubuntu, use the following steps
-
At https://github.com/settings/tokens, go and generate a token.
-
git push
-
username: user_github_username
-
password: add_generated_token
instead of the password.
Solution 9 - Git
A one-command simple solution to solve it
If your computer has no SSH key added to the GitHub account, I add information for you to do it at the end of the answer. You should do it first.
After push failed, then do this:
git remote set-url origin git@github.com:{user_id}/{project_name}.git
And push again. Then it works.
Let me show my case in the following.
(And I will guide you on how to do your case.)
At the first, when I add, commit, and push, then I meet this issue:
And then, my current Git log is the following.
In the final, this is my way to solve the issue.
In my case,
-
{project_name} <-> open-idea-pool
-
{user_id} <-> milochen0418 is the
-
{branch_name} <-> master
(your branch_name maybe is main, but not master)
When I push failed, the only thing I need is this one command:
git remote set-url origin git@github.com:{user_id}/{project_name}.git
Then I push it again by:
git push -u origin {branch_name}
For the example of my case,
git remote set-url origin git@github.com:milochen0418/open-idea-pool.git
git push -u origin master
It works.
-- By the way, this is the process of creating an SSH key to GitHub account.
You can refer to these two links to do it. The information here supports Mac, Windows, and Linux.
- https://stackoverflow.com/questions/35612504/issue-on-adding-ssh-key-to-github/35612800#35612800
- Adding a new SSH key to your GitHub account
Furthermore, if you want to clone a new project, you can do the following command:
git clone git@github.com:{user_id}/{project_name}.git
Solution 10 - Git
Simplest solution (at the time of editing May 2022 ):
- Create a new token at Personal access tokens
- Copy token (Windows: Ctrl + C, macOS: Cmd + C, or click copy icon)
- Try to push your local repository:
git push
- Enter your GitHub user name
- Paste the token as your password
Solution 11 - Git
If you're using macOS and do not find the github.com entry in the KeyChain access:
-
Try to do a Git action
-
It'll ask for the user name
-
Enter your GitHub user name
-
Generate a new key from Personal access tokens
-
In the password field, enter this newly generated token value
-
Now you can see a new entry of github.com inside KeyChain Access → login
Solution 12 - Git
For Mac, go and create your token. You can only see it once. Copy it and store it securely.
Open up Terminal and run: gh auth login
*gh can be installed using Homebrew
Answer the questions. Make sure you pick HTTPS when asked.
Solution 13 - Git
Generating a GitHub personal access token (PAT)
- Log in to your GitHub account and open Settings → Developer Settings Personal Access Tokens.
- Click on
Generate New Token
.
> Do not forget to copy and the token after generation. It is accessible only once.
Windows
- Open Control Panel → User Accounts → Credential Manager.
- Now, look for
git:https://github.com
. - Click on Edit.
- Replace the password with the GitHub Personal Access Token.
MAC
- Click on Spotlight Icon and search for
Keychain Access
. - Inside Keychain Access, search for github.com.
- Now, look for the internet password entry for github.com.
- Update the entry.
Solution 14 - Git
I was using git pull
on Linux with a password before.
If that is the case, the only thing you need to do is use token in place of password.
Generate an access token by going to Personal access tokens.
Here is example of git pull
git pull
Username for 'https://github.com': gitusername
Password for 'https://[email protected]': //Then enter generated token
Solution 15 - Git
Go to Settings → Developer settings → generate a new token if it does not exist.
Or copy the token if it exists.
Then set the token:
git remote set-url origin https://<token>@github.com/<username>/<repo>.git/
Solution 16 - Git
First create the token on GitHub:
- Click on the profile picture and in the menu select Settings
- Select Developer Settings in the left menu at the bottom
- Select Personal Access tokens in the left menu (third option)
- Select Generate new token and follow the next steps.
If you have not installed GitHub CLI, you would not find it in your keychain Access. Therefore you should install it first.
-
Install GitHub CLI for macOS
brew install gh
For Windows:
winget install gh scoop install gh choco install gh
-
On the command line, enter
gh auth login
, follow the prompts, and provide the following answers? What account do you want to log into? GitHub.com
? What is your preferred protocol for Git operations? HTTPS
? Authenticate Git with your GitHub credentials? Yes
? How would you like to authenticate GitHub CLI? Paste an authentication token
-
Paste the token you created on GitHub and press Enter.
Solution 17 - Git
Mac users -- a simple solution.
Set up the personal access token in GitHub:
Settings → Developer Settings → Personal access token
Open Keychain → type "GitHub"
Change the password to the personal access token.
Try commit/pushing.
Select "Always allow" and business is as usual.
Solution 18 - Git
It worked!
After getting the token key as said here:
> Create Personal Access Token on GitHub From your GitHub account
>
> go to Settings => Developer Settings => Personal Access Token => Generate
> New Token (Give your password) => Fillup the form => click Generate
> token => Copy the generated Token (it will be something like
> ghp_sFhFsSHhTzMDreGRLjmks4Tzuzgthdvfsrta
)
use the following in your terminal:
git clone https://your_username:[email protected]/username/private-repo.git
Solution 19 - Git
To those using Sourcetree with an existing repository you must update your repository URL like so
https://<your_token>@github.com/username/repo.git
This was taken from this answer.
Solution 20 - Git
In Linux, you can generate a new access token in GitHub and directly replace it in place of the password in the ~.git-credentials
file.
The password section starts with :
and ends with @
.
Solution 21 - Git
I was not able to clone the project that was always giving this error. The solution I encouraged was, after having generated the token as the post was spoken in the post, I did as described below.
Using a personal access token for the cloning of a new project.
For cloning, also you just need to modify the URL as you have done in step 2.
The older way to clone a repository:
git clone repository_URL folder_name
git clone https://github.com/<user>/<repository> my_project
The new way of cloning with a personal access token:
git clone https://<token>@github.com/<user>/<repository> my_project
I share my solution.
Solution 22 - Git
As a security precaution, GitHub automatically removes personal access tokens that haven't been used in a year. To provide additional security, we highly recommend adding expiration to your personal access tokens.
Just follow Creating a token.
Solution 23 - Git
For Mac users
Generate a token and set it in the keychain.
This quick video explains it well.
For Windows Users
Just instead of the keychain, you need to set up Credential Manager with the newly generated token.
Solution 24 - Git
A quick solution for Windows users
Open Credential Manager and just remove the already-saved credentials for Git: https://github.com.
After this step, run the command again for pull/push in the terminal. GitHub will ask to log in with your default browser automatically (make sure you are logged in with GitHub in the default browser).
After successful login, we got this message:
For more help related to this, you can also watch this video.
Solution 25 - Git
Run these commands inside your project directory if the project was cloned before 13 Aug 2020:
git remote set-url <remote_name> <remote_url>
git pull
Type your username and personal access token as the password.
Solution 26 - Git
In three commands:
First create a token as indicated in the official documentation: Creating a personal access token
Then reset the Git credentials
git config --global --unset credential.helper
Clone or pull your repositories:
`git pull` or `git clone`
Then enter the token as your password.
If you want to save your token, you can use:
git config --global credential.helper cache
Solution 27 - Git
For people who want to use Sourcetree:
Just copy like this at the source path:
https://<token>@github.com/<username>/<repo>
Solution 28 - Git
If you want to clone for first time:
git clone https://<repository_owner>:<personal_access_token>@github.com/<repository_owner>/<repo>.git
Solution 29 - Git
after getting the token key, you can just skip all steps and go with this >>
git clone https://your_username:[email protected]/username/private-repo.git
Solution 30 - Git
You can force your machine to just use ssh instead of https:
git config --global url."git@github.com:".insteadOf "https://github.com/"
Solution 31 - Git
Android Studio Arctic Fox Solution (Windows 10)
I was authenticated in Android Studio Arctic Fox (latest version) using a personal access token, but still, I was getting this error on August 14, 2021:
remote: Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
I generated a new access token on github.com, removed my GitHub account from Android Studio, and added the account again with the new access token. But still, it was showing the same error.
Reading other solutions on Stack Overflow, I downloaded the GitHub CLI, and added my GitHub account in the Windows command prompt with the access token successfully, and tried to push the repository from Android Studio again, which again failed.
Then following this article, I did the following at the command line:
cd <project-directory>
git remote set-url origin https://<TOKEN>@github.com/<user_name>/<repo_name>.git
I pushed again from Android Studio, and it worked finally!
Solution 32 - Git
Recently GitHub updated their remote: Support for password authentication. Which was removed on August 13, 2021 to use PAT (personal access token) instead for accessing the GitHub API.
You can read about in the blog post here.
Now to enable PAT
- Log in to your GitHub account.
- Follow this write-up for the next actions.
Now to use the token on the command line, do this:
git clone https://github.com/username/repo.git
Username: your_username
Password: your_token
Note that your token has an expiry time and must be kept privately and used whenever you need to authenticate on the command line.
Heads up
If your are cloning into a repository that is owned by an:
Organisation
- Make sure your are member of that organisation
Or if some personal repository,
- Make sure you have enabled the following
The organisation/personal will need to enable remote cloning and forking like so:
- Go to organisation settings:
Solution 33 - Git
The best solution I have found so far:
-
Install GitHub CLI,
brew install gh
or check how to install for other OSes -
Type
gh auth login
in your terminal -
Follow through like this:
What account do you want to log into? Choose GitHub.com What is your preferred protocol for Git operations? Choose HTTPS Authenticate Git with your GitHub credentials? Choose Yes How would you like to authenticate GitHub CLI? Choose Login with a web browser (Copy the one-time code and paste in the browser) Press 'Enter' to open github.com in your browser
Solution 34 - Git
For those who followed the instruction to generate the Personal access tokens, but forgot to select suitable scopes:
Please do remember to choose suitable scopes like repositories. You won't get a different error prompt whether you use the previous password or a new token without a suitable scope.
Solution 35 - Git
For anyone who uses Sourcetree as the Git client, open Preferences → go to the Accounts tab → Add GitHub account → Auth type = basic → fill in your GitHub account and the access tokens from GitHub you created as a password → Use HTTPS protocol → done!
Solution 36 - Git
- Use SSH (forget https) (E.g., don't use https url for cloning)
- Use Personal Access Token (PAT) (forget username/password)
> (e.g., Settings > Developer Settings > Personal Access Token)
- Update git to latest version (e.g., 2.35.1) //I think this is important
- In Github, Uncheck Settings > Developer Settings > Keep my email addresses private
Conclusion: You add Personal Access token in Github. Then from any IDE (e.g., Android Studio, IntelliJ IDEA etc.) you can add remote using ssh (e.g., name: origin, URL: [email protected]:your_github_username/your_git_repo.git. That's it
If not already done,
-
Configure git global username and email
> git config --global user.name "your_username" && git config --global user.email "your_email"
If in windows, you can add windows credentials for your user, control panel > users > manage your credential > Windows Credentials > Add a generic credential >
> Internet address will be git:https://github.com and you need to type > in your username and password will be your GitHub Personal Access > Token => Click Ok and you are done
After this I was able to use git (fetch/push/pull etc.)
Solution 37 - Git
> Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
Solution
- Create a GitHub personal access token (PAT) and copy it.
- For MacOS, add it to KeyChain Access under GitHub.
Spotlight Search > type KeyChain > select KeyChain Access > search for github.com > paste your PAT
For Windows, add the PAT to Windows credentials for your user.
Search > type Credential Manager > Add your PAT to github.com
- If the repo is part of an organization, you will also need to sign in to that organization with your personal access token so that the organization will recognize it. If you're already signed in, sign out first.
git clone
as usual :-)
Solution 38 - Git
Yesterday I had some issues trying to find GitHub on the Keychain in my MacBook. I've tried a lot of ways with no success.
From my perspective, the workaround I've used to be able to pull and push from my GitHub account fast, was doing it by SSH.
This allowed me to do it with no further configuration.
- You can do it going to SSH keys
- Then New SSH key
- If you already created an SSH locally, just run
pbcopy < ~/.ssh/id_rsa.pub
in your terminal - Then pull, push, clone or whatever you need from your GitHub repository and it's done
I know this is not the solution to the issue, but it worked for me since I needed to do it fast and to me to be honest there isn't any reason that I need to use HTTPS instead of SSH.
Solution 39 - Git
-
Create a personal access token (PAT) for your account. See here to create your PAT. Your PAT should start with ghp_
-
Open you Keychain Access app, search for GitHub, and delete your existing saved passwords
-
Go back to your terminal and try pushing your commit. It should prompt for your user name and password. Now, try entering your PAT in place of your usual GitHub password/passphrase.
Solution 40 - Git
I am not sure what really helped, but I know it works for me now. This is everything I've done in order:
-
Generated the PAT and used as password - it didn't work.
-
Cleared the github.com entry in the Windows Credential Manager - not working.
-
Added the PAT to the repository URL like this
https://<personal-access-token>@github.com/<my-repo-url>
- it worked, but I didn't like this solution.
-
Restarted PC. Installed the newest Git from https://git-scm.com - and in Sourcetree - menu Tools → Options → Git → Git Version - selected "System".
-
Removed the PAT from repository URL - it still works.
To me it looks like installing the new "Git" really helped, so step 3 may be unnecessary, but I can't be sure about that. I don't know if it would work without temporarily adding PAT to the URL. Maybe it also saved something somewhere.
Solution 41 - Git
For macOS users, just simply follow these steps:
(I have taken this part from Kartik Tyagi but added one of the crucial part that has been missed)
- Go to this link: https://github.com/settings/tokens (Profile -> settings -> developers setting -> personal access tokens). (don't go to repository setting; it's your profile setting)
- Generate a new token and copy-paste it somewhere safely.
- Now search for an app in your Mac, named
Keychain Access
. - Search for
github.com
.
If it is not present:
5.1. Click on "Create a new Keychain Item" button (the notepad-pen icon).
Keychain Item Name: https://github.com
Account Name: https://github.com
(Must keep it like this. Do not add www
. It will not work properly then)
Password: Paste the token you generated
If it is present:
5.2. If there are multiple GitHub logins then choose Kind: Internet password
, double-click it.
- Click on show password, then enter your Mac's password and hit Enter.
- Password should be visible by now. Now, just paste the token you generated in step 2 and click Save changes.
And that should be it. Enjoy!
Solution 42 - Git
I spent a few hours on this issue, with WSL 2 (Ubuntu 20.04 (Focal Fossa)). Opening a new shell worked for me. Trying the old shell, it did not work.
I am also investigating GitLab as maybe they don't have the Microsoft culture of forcing you do to things their way ("You will prefer it this way") or releasing breaking changes all the time.