browse_github_token: Create and retrieve a GitHub personal access token

Description Usage Arguments Value See Also Examples

Description

A personal access token (PAT) is needed for git operations via the GitHub API. Two helper functions are provided:

Usage

1
2
3
4
5
6
7
browse_github_token(scopes = c("repo", "gist"),
  description = "R:GITHUB_PAT", host = "https://github.com")

browse_github_pat(scopes = c("repo", "gist"),
  description = "R:GITHUB_PAT", host = "https://github.com")

github_token()

Arguments

scopes

Character vector of token scopes, pre-selected in the web form. Final choices are made in the GitHub form. Read more about GitHub API scopes at https://developer.github.com/apps/building-oauth-apps/scopes-for-oauth-apps/.

description

Short description or nickname for the token. It helps you distinguish various tokens on GitHub.

host

GitHub API host to use. Override with the endpoint-root for your GitHub enterprise instance, for example, "https://github.hostname.com/api/v3".

Value

github_token() returns a string, a GitHub PAT or "".

Get and store a PAT: Sign up for a free GitHub.com account and sign in. Call browse_github_token(). Verify the scopes and click "Generate token". Copy the token right away! A common approach is to store in .Renviron as the GITHUB_PAT environment variable. edit_r_environ() opens this file for editing.

See Also

gh::gh_whoami() for information on an existing token.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
## Not run: 
browse_github_token()
## COPY THE PAT!!!
## almost certainly to be followed by ...
edit_r_environ()
## which helps you store the PAT as an env var

## End(Not run)
# for safety's sake, just reveal first 4 characters
substr(github_token(), 1, 4)

usethis documentation built on July 4, 2019, 5:05 p.m.