DEV Community

Cover image for Token authentication requirements for Git operations
Sedrick Tha Dev
Sedrick Tha Dev

Posted on

Token authentication requirements for Git operations

Hi guys!
Github recently some emails warning us about some of the deprecated methods of authentication we were using to push, clone etc on our repos. And incase there were some like me, we ignored this til the day it all stopped working and got stuck.

Anyway, don't worry. There's an easy I found to fix this asap.

Login to your github account and follow the next steps:

  1. In the upper-right corner of any page, click your profile photo, then click Settings. Settings icon in the user bar

    1. In the left sidebar, click Developer settings. Developer settings
    2. In the left sidebar, click Personal access tokens. Personal access tokens
    3. Click Generate new token. Generate new token button
    4. Give your token a descriptive name. Token description field
    5. To give your token an expiration, select the Expiration drop-down menu, then click a default or use the calendar picker. Token expiration field
    6. Select the scopes, or permissions, you'd like to grant this token. To use your token to access repositories from the command line, select repo.
    7. Selecting token scopes
    8. Click Generate token. Generate token button
    9. Copy safe your Newly created token as you will use this as your password every timeyou want to perform a push.

**** Warning: Treat your tokens like passwords and keep them secret. When working with the API, use tokens as environment variables instead of hardcoding them into your programs.

Using a token on the command line ###########

Once you have a token, you can enter it instead of your password when performing Git operations over HTTPS.

For example, on the command line you would enter the following:

$ git clone https://github.com/username/repo.git
Username: your_username
Password: your_token

Happy Coding!

Top comments (0)