Search code examples
gitpersonal-access-token

Still recieving "Please use a personal access token instead." despite using personal access token


I know there's been questions about this previously, but I am still getting an annoying error when trying to push a repository:

git push --set-upstream origin main
Username for 'https://github.com': xxx
Password for 'https://[email protected]':

After I enter my personal access token, it errors out with:

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/sahwa/thesis.git/'

I have created an access token and been using is successfully for a while, but git will still return the above error occasionally for no apparent reason. I am using git version 2.32.0.

I should add that a) this is a new personal access token that isn't expired and b) has all of the correct scopes selected.

Does anyone know how to resolve this?


Solution

  • The issue is likely your remote, which is set automatically when you git clone!

    You can see and change the remote to the git protocol, rather than https as

    git remote -v  # display
    git remote set-url origin [email protected]:User/UserRepo.git