Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Update GitHub authentication to use token on macOS (rather than password)?

After creating a token, how do you unset the existing password and use the token instead?

I tried running osxkeychain command git config --global credential.helper osxkeychain but it doesn't change anything. I also tried unsetting the user password with git config --global --unset user.password, and I tried opening Keychain Access application and delete GitHub entries, but neither worked.

like image 380
stevec Avatar asked May 22 '21 05:05

stevec


People also ask

How do I update my git access token Mac?

Updating an existing Access Token If your existing token has expired, or been revoked, or you are on a new machine and do not have access to the existing token then you can regerate a new one in the Github console Settings -> Developer settings -> Personal access tokens .

How do I update my GitHub token in Terminal Mac?

Updating your credentials via Keychain AccessType Keychain access then press the Enter key to launch the app. In Keychain Access, search for github.com. Find the "internet password" entry for github.com . Edit or delete the entry accordingly.

How do I add a GitHub personal access token on my Macbook?

Making a New Personal Access TokenHead over to your personal account settings to generate a new token. Scroll down to “Developer Settings.” Select “Personal Access Tokens,” and generate a new one: You'll need to verify your actual account password. Give the token a name, and select an expiration date.

How do I update my GitHub access token?

However, regardless of the case you are facing, I will explain how to update your personal access token using the terminal. Go to the personal access token of your GitHub account. Open menu from the top right corner next to your profile picture. Click on Settings. Click on Developer Settings. Click on Personal access tokens.

How to store Git credentials in the osxkeychain?

You can tell Git you want to store credentials in the osxkeychain by running the following:- Now issue a command to interract with Github which requires authentication, eg. git clone or git pull. When you are prompted to supply your Password for ' https://[email protected] ': you enter your access token instead.

How do I Find my GitHub token on a Mac?

Use the mac search for "keychain" and open Keychain Access.app Search for GitHub. You may see two options: an application password and an internet password Open the application password. You may check the box for "Show password and likely see that this still uses your password rather than the token.

How do I create a GitHub Keychain Access token?

For more information, see " Creating a personal access token ." Click on the Spotlight icon (magnifying glass) on the right side of the menu bar. Type Keychain access then press the Enter key to launch the app. In Keychain Access, search for github.com.


Video Answer


2 Answers

Step 1

Copy this into your terminal to unset existing GitHub login credentials:

git config --global --unset credential.helper
git credential-osxkeychain erase
host=github.com
protocol=https

Step 2

Open a new terminal window, and set the name and email for commits:

git config --global user.name "Your Name"
git config --global user.email [email protected]

Step 3

Run a git push or git clone a private repository so GitHub prompts you to enter your username and password.

For the username, simply enter your email.

For the password paste in your token (i.e. copy the token from GitHub website where you created it and paste it in).

like image 78
stevec Avatar answered Oct 25 '22 18:10

stevec


The below command worked for me on mac as mentioned in https://gist.github.com/jonjack/bf295d4170edeb00e96fb158f9b1ba3c.

security delete-internet-password -l github.com

After running this command in terminal, run a git clone command and it will ask you the username and password. On password please provide your access token which you created from the github web portal.

like image 42
Alwin Jose Avatar answered Oct 25 '22 18:10

Alwin Jose