Git

Git “Use a Personal Access Token Instead” Error

GitHub is one of the largest and most popular online version control system for any developer and organizations. It contains a large percentage of open source and closed source in the world and facilitates the developers to create and collaborate on various projects.

However, when pushing changes to a GitHub-hosted repository, you might encounter an error such as “support for password authentication was removed. Please use a personal access token instead”.

In this tutorial, we will explore the cause/source of this error and how we can fix it when working with a Git repo.

Cause

As of August 2021, GitHub introduced the feature for any users to use the token-based authentication in order to perform various authenticated Git repositories.

This removed the feature of using the account passwords when authenticating to GitHub using REST API.

As a result, attempting to access or perform any authenticated operation on a GitHub-hosted repository using password authentication will result in the said error.

Solution

Let us proceed and discuss how you can quickly fix this error when attempting to push the code on the remote repository.

The method to fix this error is to enable and configure the access token on GitHub which allows us to perform the token-based authentication when running the Git operations.

To enable the access on token-based authentication, start by logging into your GitHub account and head over to the “Settings”.

In the “Settings” page, scroll down and look for the “Developer Settings” option.

In the “Developer Settings” window, select the “Personal Access Tokens” and choose “Tokens (Classic)”.

At the top-right, choose “Generate new token” and select “Generate new token (classic)”.

In the next step, fill the details for the “Note” section and then set an expiration date for the access token. It is recommended to set an expiration date although GitHub allows you to create a non-expiring token.

Under the “Scope” section, enable the following scopes for your token:

  1. workflow
  2. delete:packages
  3. admin:org
  4. admin:public_key
  5. delete_repo
  6. admin:enterprise
  7. project
  8. admin:gpg_key
  9. admin:ssh_signing_key

Click on “Generate Token” with the selected scope.

Next, copy the resulting token.

Paste it into the password field when running the Git command.

This should help you fix the “please use a personal access token instead” error when performing changes to a remote GitHub repository.

Conclusion

In this tutorial, we learned about the cause and the solution for the Git “support for password authentication was removed. Please use a personal access token instead” error when pushing changes to a GitHub repository.

About the author

John Otieno

My name is John and am a fellow geek like you. I am passionate about all things computers from Hardware, Operating systems to Programming. My dream is to share my knowledge with the world and help out fellow geeks. Follow my content by subscribing to LinuxHint mailing list