Setting Up Your Personal Access Tokens With GitHub.

I was working with the git command line on the Amazon Web Services (AWS) platform. I tried authenticating my user name and password to push some changes I made remotely to my GitHub repository and it didn't work, I got the message below on the command line.

Username for 'https://github.com/User_name/repo_name.git': "Username" Password for 'https://"User_name"@github.com/User_name/repo_name.git': remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/user_name/repo_name.git/'

It prompted me to do some reading. I will share my findings in this article.

How Do You Authenticate Using GitHub?

The reason the command threw that error message was that it needed me to type in personal access tokens. This token will replace your password.

This token can be used instead of a password for git over HTTPS.

The following are the steps to take.

  • Click on the top right on your GitHub page where your image is displayed.
  • Click on settings.

Annotate.jpg

  • After clicking on settings, click on developers settings.

Annotate (1).jpg

  • The developer's settings consist of the GitHub Apps, OAuth Apps and personal access tokens option.

  • Click on the Personal access tokens options.

Annotate (2).jpg

  • When you get to the personal access tokens page, click on generate a new token

Annotate (3).jpg

After generating the new token make a copy of it as it gets generated, because it disappears after then.

Now paste in the personal access token where your password is required on the command line.

Username for 'https://github.com/user_name/repo_name.git': user_name Password for 'https://user_name@github.com/user_name/repo_name.git':

One important thing to note is that when generating the personal access token you'll be asked what the token is for, which means you have to pick from the scope listed on the page.

The diagram below shows the page, the prompt box to type the scope you want and the list of scopes. I picked repo & workflow when I created mine.

Annotate (4).jpg

For further reading about scopes check out this link below.

Thank you for reading.