How to update Github’s Personal Access Token on a local machine?

Categorized as Misc

To update your Personal Access Token on a local machine, follow these steps:

  1. Go to your GitHub settings page. You can find this by clicking on your profile picture in the top right corner of the page and selecting “Settings” from the drop-down menu.
  2. In the left-hand menu, click on “Developer settings.”
  3. Under “Personal access tokens,” click on the “Generate new token” button.
  4. Give your token a name and select the desired scopes. Scopes control what your token can access on GitHub.
  5. Click the “Generate token” button.
  6. Copy the generated token and store it in a secure location.

Now, update locally

Replace the old token in your local machine with the new one. This will depend on how you are using the token. For example, if you are using it to authenticate with the GitHub API, you will need to update the token in your code or configuration file.

If you are using SourceTree app on Mac, go to Spotlight search, find Keychains, delete the github.com Access Key. Then, when you try to fetch or pull anything via SourceTree, it will ask you for the credentials. Put in you new access token and that is it!

Github Keychains

If you are using VSCode, you can update your Personal Access Token manually, by this command:

git remote set-url origin https://user:ghp_g95p5Rm****[email protected]/user/example.git

All you have to do is to specify your username and token for the repository url.

Note: It is a good practice to rotate your Personal Access Tokens regularly to ensure the security of your account.

Leave a reply

Your email address will not be published. Required fields are marked *