others-How to update github access token?

1. Purpose

In this post, I would try to demonstrate how to update github access token. Because I received an email from github which said:

Hey @bswen,

Your personal access token “git command line script usage” with repo scope has expired.

If this token is still needed, visit https://github.com/settings/tokens/….. to generate an equivalent.

If you run into problems, please contact support by visiting https://github.com/contact?tags=dotcom-accounts

Thanks, The GitHub Team



2. The solution

2.1 What is github personal access token?

Personal access tokens (PATs) are an alternative to using passwords for authentication to GitHub when using the GitHub API or the command line. If you want to use a PAT to access resources owned by an organization that uses SAML SSO, you must authorize the PAT.



2.2 How to update my github personal access token on MACOSX?

1) You can check if you have an existing password or token stored in the osxkeychain using the following command.

security find-internet-password -l github.com

For me , I got this result:

➜  bswen-project git:(master) security find-internet-password -l github.com
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.

If you get some result, just delete it:

security delete-internet-password -l github.com

Then set osxkeychain as credential.helper:

git config --global credential.helper osxkeychain

Then try again (when prompting for password, input your access token instead):

➜  bswen-project git:(master) git push
Username for 'https://github.com': bswen
Password for 'https://[email protected]':
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 299 bytes | 299.00 KiB/s, done.
Total 3 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), completed with 2 local objects.
To https://github.com/bswen/bswen-project.git
   57a88d4..abc3efd  master -> master

It works now!



3. Summary

In this post, I demonstrated how to update personal access token(or PAT) of github.com, the key point is to find and delete your local credential with commands . That’s it, thanks for your reading.