Learn R Programming

ghclass (version 0.2.0)

github_token: Tools for handling GitHub personal access tokens (PAT)

Description

  • 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

Usage

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

Run this code
# NOT RUN {
github_test_token()

pat = github_get_token()

github_set_token("bad_token")
github_test_token()

github_set_token(pat)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab