Github password authentication has been removed

Personal access tokens to the rescue

As of August 13th 2021 GitHub removed support for user/password authentication when pushing code upstream. Using the user/password combination from the CLI will result in the following 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 'https://github.com/webweaves/jee7-template.git/': The requested URL returned error: 403

We resolve this issue with the use of GitHub personal access tokens

Generate a new access token 

GitHub -> Settings -> Developer Settings -> Personnel access tokens -> Generate new token

Give your access token a name and an expiry date, in my example I've set the token to expire in 1 year. Finally check the repo checkbox, this enables clients using this token to have access to your public and private repositories. 

New personal access token

Your newly create token will now appear in your list of tokens available to you. Take a copy of the token, you'll need it in the next step.

Configuring your local Git config to use your token

Next we need to add a new remote to our git config which makes use of the token

git remote add origin https://MyDevelToken:[email protected]/webweaves/jee7-template.git

This added a new remote to the .git/config file, all future pushed will make use of this config using the new token, no more authentication prompts!

If you've made a mistake with the token remove it with 

git remote remove origin

If the config is good then you can run a git push and not have to worry about authenticating each time

git push --set-upstream origin main

Bear in mind the token is stored locally un-encrypted, take a look at the git credential system to avoid plain text tokens

Tags:
github
personal token

v1.9.1

© ScottFreeIT.com 2020