Have you ever tried to push or pull code to or from Github, and received the message:
Password authentication is temporarily disabled as part of a brownout. Please use a personal access token instead.
Or another error message in the form:
Support for password authentication was removed on August 13, 2021. Please use a personal access token instead.
This is because Github is moving/has already moved away from the less secure password authentication. In this post, we are going to see how easy it is to transition to personal access tokens in authentication.
1. Generating Personal Access Tokens
To start using a token, you should create one from your Github acccount. Use the instructions here and move to the next step.
2a. macOS Users
For mac users, most of the time the password will have been stored in the Keychain Access. Some IDEs also store your Github credentials in the same place but with a different name.
The best you can do is delete the stored credentials using the command line:
git credential-osxkeychain erase host=github.com
If nothing is returned then it has run successfuly.
When you push or clone a repository, you will now be prompted with a username and password, and the password credential is where you fill the new token.
2b. Windows Users
Windows stores different passwords in the Credential Manager. To clear stored credentials related to Github, open the Control Panel and find the Credential Manager.
In the list under Manage your Credentials, find all the credentials matching gihub.com and delete them.
From now you will be prompted with a username and password when trying to push or pull a repository, and you will have to enter the new token as your password.
3. Caching Credentials
Sometimes it can be very annoying to keep typing the username and personal access token every time to clone, push to or pull from a repository. The best solution would be to cache your credentials using the Git Credential Manager Core, a method that does not require a personal access token.