Skip to content

Commit

Permalink
Better advice re PATs
Browse files Browse the repository at this point in the history
Closes #133.
  • Loading branch information
gaborcsardi committed Apr 30, 2021
1 parent b7263ad commit d814901
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 36 deletions.
30 changes: 11 additions & 19 deletions R/gh_whoami.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,26 @@
#'
#' Reports wallet name, GitHub login, and GitHub URL for the current
#' authenticated user, the first bit of the token, and the associated scopes.

#'
#' 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.
#' You can store it any way you like and provide explicitly via the `.token`
#' argument to [gh()].
#'
#' However, many prefer to define an environment variable `GITHUB_PAT` (or
#' `GITHUB_TOKEN`) with this value in their `.Renviron` file. Add a
#' line that looks like this, substituting your PAT:
#' 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:
#'
#' ```r
#' gitcreds::gitcreds_set()
#' ```
#' GITHUB_PAT=8c70fd8419398999c9ac5bacf3192882193cadf2
#' ```
#'
#' Put a line break at the end! If you're using an editor that shows line
#' numbers, there should be (at least) two lines, where the second one is empty.
#' Restart R for this to take effect. Call `gh_whoami()` to confirm
#' success.
#'
#' To get complete information on the authenticated user, call
#' `gh("/user")`.
#' See https://usethis.r-lib.org/articles/articles/git-credentials.html
#' for more about managing GitHub (and generic git) credentials.
#'
#' For token management via API (versus the browser), use the
#' [OAuth Authorizations API](https://docs.github.com/v3/oauth_authorizations/).
#' This API requires Basic Authentication using your username and password,
#' not tokens, and is outside the scope of the gh package.
#' 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.
#'
#' @inheritParams gh
#'
Expand Down
27 changes: 10 additions & 17 deletions man/gh_whoami.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d814901

Please sign in to comment.