Consults environment variables for a GitHub personal access token (PAT). By
default, looks for GITHUB_PAT and GITHUB_TOKEN, in that order.
Conventions followed by other packages at the time of writing:
git2r and devtools look for GITHUB_PAT,
gh looks for GITHUB_TOKEN. Obtain a PAT from
https://github.com/settings/tokens. Unless you have a specific reason
to request otherwise, the default scopes are probably sufficient.
Usage
gh_pat(envvar = c("GITHUB_PAT", "GITHUB_TOKEN"))
Arguments
envvar
Name of the environment variable in which the GitHub personal
access token is stored. Can be a character vector, with names in order of
preference.
Value
The GitHub personal access token, invisibly.
Details
How to store your PAT in an environment variable?
Identify your home directory. Not sure? Enter
normalizePath("~/") in the R console.
If you don't already have a file here named .Renviron, create
one. If you have one already, open it for editing.
Add a line like this: GITHUB_PAT=blahblahblahblahblahblah, where
blahblahblahblahblahblah is your PAT. Make sure the last line in the
file is empty. Otherwise R will silently fail to load the file.
Save. And yes you do want to use a filename that begins with a dot.
Restart R. .Renviron is processed only during
Startup.
Check your work with Sys.getenv("GITHUB_PAT"). Your PAT should
print to screen.