Configure authorizedVerb to use GitHub personal access tokens for authentication. This is a useful default approach when no better authentication scheme is available.

setGitHubToken(
  token,
  cache.env,
  cache.path = NULL,
  github.url = "https://api.github.com",
  prompt.text = NULL
)

getGitHubTokenInfo(cache.env, cache.path = NULL, prompt = interactive(), ...)

useGitHubIdentities(cache.env, cache.path = NULL, ...)

Arguments

token

String containing a GitHub personal access token. If missing, the user will be prompted to supply a token. If NULL, any existing tokens are cleared.

cache.env

Environment to use to store the current GitHub token in an in-memory cache. This allows the same token to be transparently re-used in the same R session.

cache.path

String containing a path to a on-disk cache. This allows the same token to be transparently re-used across different R sessions. If NULL, no on-disk caching is performed.

github.url

String containing the URL to a GitHub REST API.

prompt.text

String containing the prompt text for an interactively supplied token.

prompt

Logical scalar indicating whether the user should be prompted to supply token details if no cached token exists.

...

Further arguments to pass to setGitHubToken when prompting for a new token.

Value

For setGitHubToken, any non-NULL

token (or its interactively supplied counterpart) will be cached in memory and/or on disk, depending on cache.path. A list is invisibly returned containing details about the token including its value, the corresponding user account and the expiry time. If token=NULL, any cached token is cleared from disk and memory, and NULL is invisibly returned.

For getGitHubTokenInfo, a list is returned containing the token details. If prompt=FALSE and no cached token is present, NULL is returned.

For useGitHubIdentities, the availability and value of the token is used to configure identityAvailable and identityHeaders. A function is returned that, when executed, restores the previous values of identityAvailable and identityHeaders; this is typically run in an on.exit clause.

Author

Aaron Lun

Examples

if (FALSE) setGitHubToken()

cache.env <- new.env()
cache.path <- tempfile()
getGitHubTokenInfo(cache.env, cache.path, prompt=FALSE)
#> NULL