Configure and Set a Personal Access Token (PAT)
Scope
This document outlines the steps you can take to create and set a GitHub Personal Access Token.
Create and Set a GitHub Personal Access Token (PAT)
Some tools that interface with Git require you to have a GitHub Personal Access Token (PAT) set up. Follow the steps below to create and set your GitHub PAT.
Create a Personal Access Token (PAT)
Follow the below steps to create your PAT:
1. Log into GitHub.
3. Navigate to Developer Settings
4. Select Personal access tokens
6. Describe token and assign permissions
Give your token a description that will help you identify it later. In
the "Select scopes" section, select everything under the "repo: Full
control of private repositories" group. Then, scroll down and click the
"Generate token" button.
7. Save your token locally
On the next page, you will have an opportunity to copy your token, which
will be a long string of characters. Save your token somewhere ON YOUR
COMPUTER. For security reasons, it is imperative that your token never
be checked in to GitHub, GitHub Enterprise (GHE), Google Drive, etc.
You will not be able to retrieve this token from GitHub later. (The
token in these images has been deleted.)
Set the GitHub PAT Environment Variable In R
Per session
Once you have created a personal access token, you must set it as an environment variable in each R session that will need it. Run the following code snippet in R to set your PAT for the session:
# Set the GITHUB_PAT environment variable to your generated token.
Sys.setenv("GITHUB_PAT" = "<Your GitHub PAT>")
# Print the current value of GITHUB_PAT to verify that it was set properly.
Sys.getenv("GITHUB_PAT")
Persistent
To persist across sessions, add the following to ~/.Renviron
:
GITHUB_PAT=<Your GitHub Enterprise PAT>
Set the GitHub PAT Environment Variable System-wide (for other applications, e.g., shell)
You will also want this variable set in your shell so you can issue shell commands against GitHub (e.g., download files from a release).
Add the following to where you typically assign env variables, likely
either ~/.bash_profile
or ~/.profile
export GITHUB_PAT="<Your Github PAT>"
You will need to load a new terminal process for these changes to be effective.