Creating your personal access token

  1. Verify your email address, if it hasn’t been verified yet.

  2. In the upper-right corner of any page, click your profile photo, then click Settings.

  3. In the left sidebar, click Developer settings.

  4. In the left sidebar, click Personal access tokens.

  5. Click Generate new token.

  6. Give your token a descriptive name.

  7. To give your token an expiration, select the Expiration drop-down menu, then click a default or use the calendar picker.

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

  9. Click Generate token. Make sure to copy it so that you can use it!

  10. 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 and caching your token

Do the follow from the terminal:

First, configure the local GIT client with a username and email address,

$ git config --global user.name "your_github_username" 
$ git config --global user.email "your_github_email" 
$ git config -l

Once GIT is configured, we can begin using it to access GitHub.

Example:

$ git clone https://github.com/YOUR-USERNAME/YOUR-REPOSITORY 
> Cloning into `Spoon-Knife`...
$ Username for 'https://github.com' : username 
$ Password for 'https://github.com' : give your personal access token here

Now cache the given record in your computer to remembers the token:

$ git config --global credential.helper cache

Now try to pull with -v to verify

$ git pull -v

If needed, anytime you can delete the cache record by:

$ git config --global --unset credential.helper 
$ git config --system --unset credential.helper

More resources

Copyright © 2014, Great Practical Ideas in Computer Science.