Forked from jonjack/add-update-refresh-github-access-token-on-mac.md
Created
December 3, 2021 23:12
-
-
Save rchuluc/1e8b9b4a1bb0d7d4cd051e55a72549d1 to your computer and use it in GitHub Desktop.
Revisions
-
jonjack revised this gist
Sep 9, 2021 . 1 changed file with 2 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -33,7 +33,8 @@ user.name=Joe Bloggs ## Updating to a new Access Token > April 2021 Notice on possible future updates on token length -> [Authentication token format updates are generally available](https://github.blog/changelog/2021-03-31-authentication-token-format-updates-are-generally-available/). If you need to regenerate the Access Token then log into your Github dashboard and navigate to `Settings / Developer settings / Personal access tokens` and choose to either `Generate new token` or replace your existing token, either by choosing `Delete` and `Generate new token`, or viewing your current token and choosing `Regenerate token`. -
jonjack revised this gist
Sep 9, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -70,7 +70,7 @@ attributes: password has been deleted. ``` Now, the next time you attempt a `clone/pull/push` etc on a private repo, the Github API should prompt you for your Username/Password. Note that you enter your new token when prompted for _Password_. ```bash Username for 'https://github.com': your_github_username -
jonjack revised this gist
Sep 9, 2021 . 1 changed file with 8 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -70,7 +70,14 @@ attributes: password has been deleted. ``` Now, the next time you attempt a `clone/pull/push` etc on a private repo, the Github API should prompt you for your Username/Password. Note that you enter your new token when prompted for _Paswword_. ```bash Username for 'https://github.com': your_github_username Password for 'https://[email protected]': your_access_token ``` The new token should get added to your local Key Chain so you should not need to specify it again until the next time you decide/need to regenerate a new one. ### To check if your access token exists in your keychain -
jonjack revised this gist
Sep 9, 2021 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -39,17 +39,23 @@ If you need to regenerate the Access Token then log into your Github dashboard a ### Remove existing token from your Keychain The general approach described in the Github documentation is to use the following git command to erase your local credentials. #### Note, it is worth reading the rest of this section before running the following command. ```bash $ git credential-osxkeychain erase ``` The above would appear to be increasingly ineffective and, as many report in the comments below, often just hangs. An alternative approach to deleting the existing token is to try the following command. ```bash $ security delete-internet-password -l github.com ``` If you had a token previously stored then running the above should output something like the following. ```bash keychain: "/Users/jblogs/Library/Keychains/login.keychain-db" version: 512 class: "inet" -
jonjack revised this gist
Jun 30, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -31,7 +31,7 @@ [email protected] user.name=Joe Bloggs ``` ## Updating to a new Access Token > April 2021 - notice on possible future updates on token length [Authentication token format updates are generally available](https://github.blog/changelog/2021-03-31-authentication-token-format-updates-are-generally-available/). -
jonjack revised this gist
Jun 30, 2021 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -85,7 +85,7 @@ attributes: 0x00000008 <blob>=<NULL> "acct"<blob>="joebloggs" "atyp"<blob>="dflt" "cdat"<timedate>=0x32303730303933373333343635395A00 "20200938235909Z\000" ...(truncated) ``` -
jonjack revised this gist
Jun 30, 2021 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -37,7 +37,7 @@ user.name=Joe Bloggs If you need to regenerate the Access Token then log into your Github dashboard and navigate to `Settings / Developer settings / Personal access tokens` and choose to either `Generate new token` or replace your existing token, either by choosing `Delete` and `Generate new token`, or viewing your current token and choosing `Regenerate token`. ### Remove existing token from your Keychain The general approach described in the Github documentation is to use the following git command to erase your local credentials. __Note, it is worth reading the rest of this section before running this.__ @@ -66,7 +66,7 @@ password has been deleted. Now, the next time you attempt a `clone/pull/push` etc on a private repo, the Github API should prompt you for your new token on the command line and entering the new token should also add it to your local Key Chain which you can check as below. ### To check if your access token exists in your keychain To check if the token still exists you can try this. -
jonjack revised this gist
Jun 30, 2021 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,15 +1,15 @@ As outlined [here](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/), there are a couple of situations where you may want/need to authenticate with GitHub by using an Access Token:- 1. If you have Two-Factor Authentication (2FA) enabled. 2. You are accessing an organisations protected content using SAML Single-Sign On (SSO). ## Using an Access Token for the first time ### Create an Access Token In your GitHub account, go to `Settings / Developer settings / Personal access tokens` and select `Generate New Token`. Make a note of the token somewhere safe since this is the only chance you get to see it. ### Add the token to your OSX Key Chain When you next clone a private repository on the command line Github should challenge you for your credentials. Even though it will prompt you for your _Password for 'https://[email protected]':_ this is actually where you should supply your new access token. -
jonjack revised this gist
Jun 30, 2021 . 1 changed file with 67 additions and 13 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,26 +1,30 @@ As outlined [here](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/), there are a couple of situations where you need to authenticate with GitHub by using an Access Token:- 1. If you have Two-Factor Authentication (2FA) enabled. 2. You are accessing an organisations protected content using SAML Single-Sign On (SSO). ## Using an Access Token for the first time #### Create an Access Token In your GitHub account, go to `Settings / Developer settings / Personal access tokens` and select `Generate New Token`. Make a note of the token somewhere safe since this is the only chance you get to see it. #### Add the token to your OSX Key Chain When you next clone a private repository on the command line Github should challenge you for your credentials. Even though it will prompt you for your _Password for 'https://[email protected]':_ this is actually where you should supply your new access token. ```bash $ git clone https://github.com/username/repo.git Cloning into 'repo'... Username for 'https://github.com': your_github_username Password for 'https://[email protected]': your_access_token ``` Using the token on your Mac the first time should automatically add it to your OSX Key Chain so that you do not need to enter it every time you are interracting with the Github API. If you check your local git configuration you should see that there is a `credential.helper` key pointing to the OSX Key Chain. ```bash $ git config -l credential.helper=osxkeychain [email protected] @@ -29,15 +33,65 @@ user.name=Joe Bloggs ## Updating the Access Token > April 2021 - notice on possible future updates on token length [Authentication token format updates are generally available](https://github.blog/changelog/2021-03-31-authentication-token-format-updates-are-generally-available/). If you need to regenerate the Access Token then log into your Github dashboard and navigate to `Settings / Developer settings / Personal access tokens` and choose to either `Generate new token` or replace your existing token, either by choosing `Delete` and `Generate new token`, or viewing your current token and choosing `Regenerate token`. #### Remove existing token from your Keychain The general approach described in the Github documentation is to use the following git command to erase your local credentials. __Note, it is worth reading the rest of this section before running this.__ ```bash $ git credential-osxkeychain erase ``` The above would appear to be increasingly ineffective and, as many report in the comments below, often just hangs. An alternative approach to delete is to try the following. ```bash $ security delete-internet-password -l github.com keychain: "/Users/jblogs/Library/Keychains/login.keychain-db" version: 512 class: "inet" attributes: 0x00000007 <blob>="github.com" 0x00000008 <blob>=<NULL> "acct"<blob>="joebloggs" "atyp"<blob>="dflt" "cdat"<timedate>=0x32303230303932383233343630395A00 "20200928234609Z\000" "crtr"<uint32>="aapl" ... (truncated) password has been deleted. ``` Now, the next time you attempt a `clone/pull/push` etc on a private repo, the Github API should prompt you for your new token on the command line and entering the new token should also add it to your local Key Chain which you can check as below. #### To check if your access token exists in your keychain To check if the token still exists you can try this. ```bash $ security find-internet-password -l github.com ``` Which should report something like this if it exists. ```bash keychain: "/Users/jbloggs/Library/Keychains/login.keychain-db" version: 512 class: "inet" attributes: 0x00000007 <blob>="github.com" 0x00000008 <blob>=<NULL> "acct"<blob>="joebloggs" "atyp"<blob>="dflt" "cdat"<timedate>=0x32303230303932383233343630395A00 "20200928234609Z\000" ...(truncated) ``` Or else if it does not exist then you should see something like this. ```bash security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain. ``` -
jonjack revised this gist
Sep 8, 2018 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -29,7 +29,7 @@ user.name=Joe Bloggs ## Updating the Access Token If you need to regenerate the Access Token (maybe you got a new Mac and didn't make a note of your existing token) then follow the procedure before in your Github account settings to generate a new token. Then, on your local Mac you can either use the Keychain Access app to delete the old token (search for Github.com in the App), or, use the following command. -
jonjack revised this gist
Sep 8, 2018 . 1 changed file with 31 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -9,5 +9,35 @@ In your GitHub account, go to `Settings / Developer settings / Personal access t ### Add the token to your local OSX Key Chain When you now need to authenticate with GitHub on the command line you will need to use the token instead of your password (even though git will ask for your Github _password_). ```bash git clone https://github.com/username/repo.git Username: your_username Password: your_token ``` Using the token on your Mac the first time should automatically add it to your OSX Key Chain so that you do not need to enter it every time you are using the Github API. If you check your local git configuration you should see that there is a `credential.helper` key pointing to the OSX Key Chain. ```bash git config -l credential.helper=osxkeychain [email protected] user.name=Joe Bloggs ``` ## Updating the Access Token If you need to regenerate the Access Token then follow the procedure before in your Github account settings. Then, on your local Mac you can either use the Keychain Access app to delete the old token (search for Github.com in the App), or, use the following command. ```bash git credential-osxkeychain erase ``` Now, the next time you do a `clone/pull/push` etc Github should prompt you for your new token on the command line and entering the new token should also add it to youe local Key Chain. -
jonjack revised this gist
Sep 8, 2018 . 1 changed file with 13 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,13 @@ As outlined [here](https://help.github.com/articles/creating-a-personal-access-token-for-the-command-line/), there are a couple of situations where you need to authenticate with GitHub by using an Acces Token:- 1. If you have Two-Factor Authentication (2FA) enabled. 2. You are accessing an organisations protected content using SAML Single-Sign On (SSO). ### Create an Access Token In your GitHub account, go to `Settings / Developer settings / Personal access tokens` and select `Generate New Token`. Make a note of the token somewhere safe since this is the only chance you get to see it. ### Add the token to your local OSX Key Chain When you -
jonjack created this gist
Sep 8, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ If you have Two-Factor Authentication (2FA) enabled on GitHub, or are accessing an organisations protected content using SAML Single-Sign On (SSO), then you will need to authenticate using an Access Token.