A personal access token (PAT) is needed for certain tasks usethis does via the GitHub API, such as creating a repository, a fork, or a pull request. If you use HTTPS remotes, your PAT is also used when interacting with GitHub as a conventional Git remote. These functions help you get and manage your PAT:
gh_token_help() guides you through token troubleshooting and setup
create_github_token() opens a browser window to the GitHub form to
generate a PAT, with suggested scopes pre-selected. It also offers advice
on storing your PAT.
gitcreds::gitcreds_set() helps you register your PAT with the Git
credential manager used by your operating system. Later, other packages,
such as usethis, gert, and gh can automatically retrieve that PAT and use
it to work with GitHub on your behalf.
Usually, the first time the PAT is retrieved in an R session, it is cached in an environment variable, for easier reuse for the duration of that R session. After initial acquisition and storage, all of this should happen automatically in the background.
Git/GitHub credential management is covered in a dedicated article: Managing Git(Hub) Credentials
1 2 3 4 5 6 7
Character vector of token scopes, pre-selected in the web form. Final choices are made in the GitHub form. Read more about GitHub API scopes at https://docs.github.com/apps/building-oauth-apps/understanding-scopes-for-oauth-apps/.
Short description or nickname for the token. You might (eventually) have multiple tokens on your GitHub account and a label can help you keep track of what each token is for.
GitHub host to target, passed to the
For a hypothetical GitHub Enterprise instance, either "https://github.acme.com/api/v3" or "https://github.acme.com" is acceptable.
create_github_token() has previously gone by some other names:
1 2 3 4 5 6 7 8
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.