Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

gh_whoami

Info on current GitHub user and token


Description

Reports wallet name, GitHub login, and GitHub URL for the current authenticated user, the first bit of the token, and the associated scopes.

Usage

gh_whoami(.token = NULL, .api_url = NULL, .send_headers = NULL)

Arguments

.token

Authentication token. Defaults to GITHUB_PAT or GITHUB_TOKEN environment variables, in this order if any is set. See gh_token() if you need more flexibility, e.g. different tokens for different GitHub Enterprise deployments.

.api_url

Github API url (default: https://api.github.com). Used if endpoint just contains a path. Defaults to GITHUB_API_URL environment variable if set.

.send_headers

Named character vector of header field values (except Authorization, which is handled via .token). This can be used to override or augment the default User-Agent header: "https://github.com/r-lib/gh".

Details

Get a personal access token for the GitHub API from https://github.com/settings/tokens and select the scopes necessary for your planned tasks. The repo scope, for example, is one many are likely to need.

On macOS and Windows it is best to store the token in the git credential store, where most GitHub clients, including gh, can access it. You can use the gitcreds package to add your token to the credential store:

gitcreds::gitcreds_set()

On other systems, including Linux, the git credential store is typically not as convenient, and you might want to store your token in the GITHUB_PAT environment variable, which you can set in your .Renviron file.

Value

A gh_response object, which is also a list.

Examples

gh_whoami()


## explicit token + use with GitHub Enterprise
gh_whoami(.token = "8c70fd8419398999c9ac5bacf3192882193cadf2",
          .api_url = "https://github.foobar.edu/api/v3")

gh

'GitHub' 'API'

v1.3.0
MIT + file LICENSE
Authors
Gábor Csárdi [cre, ctb], Jennifer Bryan [aut], Hadley Wickham [aut], RStudio [cph, fnd]
Initial release

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.