• github_get_token - returns the user's GitHub personal access token (PAT).

  • github_set_token - defines the user's GitHub PAT by setting the GITHUB_PAT environmental variable. This value can then

  • github_reset_token - removes the value stored in the GITHUB_PAT environmental variable.

  • github_test_token - checks if a PAT is valid by attempting to authenticate with the GitHub API

github_get_token()

github_set_token(token)

github_reset_token()

github_test_token(token = github_get_token())

Arguments

token

Character. Either the literal token path, or the path to a file containing the token.

Details

This package looks for the personal access token (PAT) in the following places (in order):

  • Value of GITHUB_PAT environmental variable.

  • Value of GITHUB_TOKEN environmental variable.

  • Contents of ~/.github/token file.

Examples

# \dontrun{ github_test_token()
#> Your GitHub PAT authenticated correctly.
pat = github_get_token() github_set_token("bad_token") github_test_token()
#> x Your GitHub PAT failed to authenticate.
#> └─GitHub API error (401): 401 Unauthorized #> ├─ API message: Bad credentials #> └─ API docs: https://docs.github.com/rest
github_set_token(pat) # }