Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save rchuluc/1e8b9b4a1bb0d7d4cd051e55a72549d1 to your computer and use it in GitHub Desktop.

Select an option

Save rchuluc/1e8b9b4a1bb0d7d4cd051e55a72549d1 to your computer and use it in GitHub Desktop.

Revisions

  1. @jonjack jonjack revised this gist Sep 9, 2021. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion add-update-github-access-token-on-mac.md
    Original 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/).
    > 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`.

  2. @jonjack jonjack revised this gist Sep 9, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion add-update-github-access-token-on-mac.md
    Original 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 _Paswword_.
    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
  3. @jonjack jonjack revised this gist Sep 9, 2021. 1 changed file with 8 additions and 1 deletion.
    9 changes: 8 additions & 1 deletion add-update-github-access-token-on-mac.md
    Original 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 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.
    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

  4. @jonjack jonjack revised this gist Sep 9, 2021. 1 changed file with 8 additions and 2 deletions.
    10 changes: 8 additions & 2 deletions add-update-github-access-token-on-mac.md
    Original 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 this.__
    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 delete is to try the following.
    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"
  5. @jonjack jonjack revised this gist Jun 30, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion add-update-github-access-token-on-mac.md
    Original file line number Diff line number Diff line change
    @@ -31,7 +31,7 @@ [email protected]
    user.name=Joe Bloggs
    ```

    ## Updating the Access Token
    ## 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/).
  6. @jonjack jonjack revised this gist Jun 30, 2021. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion add-update-github-access-token-on-mac.md
    Original 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>=0x32303230303932383233343630395A00 "20200928234609Z\000"
    "cdat"<timedate>=0x32303730303933373333343635395A00 "20200938235909Z\000"
    ...(truncated)
    ```

  7. @jonjack jonjack revised this gist Jun 30, 2021. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions add-update-github-access-token-on-mac.md
    Original 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
    ### 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 your access token exists in your keychain

    To check if the token still exists you can try this.

  8. @jonjack jonjack revised this gist Jun 30, 2021. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions add-update-github-access-token-on-mac.md
    Original 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 need to authenticate with GitHub by using an Access Token:-
    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
    ### 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
    ### 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.

  9. @jonjack jonjack revised this gist Jun 30, 2021. 1 changed file with 67 additions and 13 deletions.
    80 changes: 67 additions & 13 deletions add-update-github-access-token-on-mac.md
    Original 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 Acces Token:-
    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).

    ### Create an Access Token
    ## 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 local OSX Key Chain
    #### Add the token to your 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_).
    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
    Username: your_username
    Password: your_token
    $ 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 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.
    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
    $ git config -l

    credential.helper=osxkeychain
    [email protected]
    @@ -29,15 +33,65 @@ 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.
    > 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.

    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.
    #### To check if your access token exists in your keychain

    To check if the token still exists you can try this.

    ```bash
    git credential-osxkeychain erase
    $ security find-internet-password -l github.com
    ```

    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.
    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.
    ```

  10. @jonjack jonjack revised this gist Sep 8, 2018. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion add-update-github-access-token-on-mac.md
    Original 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 then follow the procedure before in your Github account settings.
    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.

  11. @jonjack jonjack revised this gist Sep 8, 2018. 1 changed file with 31 additions and 1 deletion.
    32 changes: 31 additions & 1 deletion add-update-github-access-token-on-mac.md
    Original 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
    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.



  12. @jonjack jonjack revised this gist Sep 8, 2018. 1 changed file with 13 additions and 1 deletion.
    14 changes: 13 additions & 1 deletion add-update-github-access-token-on-mac.md
    Original file line number Diff line number Diff line change
    @@ -1 +1,13 @@
    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.
    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

  13. @jonjack jonjack created this gist Sep 8, 2018.
    1 change: 1 addition & 0 deletions add-update-github-access-token-on-mac.md
    Original 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.