EVOLUTION-MANAGER
Edit File: gh_token.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Return the local user's GitHub Personal Access Token (PAT)</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for gh_token {gh}"><tr><td>gh_token {gh}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Return the local user's GitHub Personal Access Token (PAT)</h2> <h3>Description</h3> <p>If gh can find a personal access token (PAT) via <code>gh_token()</code>, it includes the PAT in its requests. Some requests succeed without a PAT, but many require a PAT to prove the request is authorized by a specific GitHub user. A PAT also helps with rate limiting. If your gh use is more than casual, you want a PAT. </p> <p>gh calls <code><a href="../../gitcreds/html/gitcreds_get.html">gitcreds::gitcreds_get()</a></code> with the <code>api_url</code>, which checks session environment variables and then the local Git credential store for a PAT appropriate to the <code>api_url</code>. Therefore, if you have previously used a PAT with, e.g., command line Git, gh may retrieve and re-use it. You can call <code><a href="../../gitcreds/html/gitcreds_get.html">gitcreds::gitcreds_get()</a></code> directly, yourself, if you want to see what is found for a specific URL. If no matching PAT is found, <code><a href="../../gitcreds/html/gitcreds_get.html">gitcreds::gitcreds_get()</a></code> errors, whereas <code>gh_token()</code> does not and, instead, returns <code>""</code>. </p> <p>See GitHub's documentation on <a href="https://docs.github.com/en/github/authenticating-to-github/creating-a-personal-access-token">Creating a personal access token</a>, or use <code>usethis::create_github_token()</code> for a guided experience, including pre-selection of recommended scopes. Once you have a PAT, you can use <code><a href="../../gitcreds/html/gitcreds_get.html">gitcreds::gitcreds_set()</a></code> to add it to the Git credential store. From that point on, gh (via <code><a href="../../gitcreds/html/gitcreds_get.html">gitcreds::gitcreds_get()</a></code>) should be able to find it without further effort on your part. </p> <h3>Usage</h3> <pre> gh_token(api_url = NULL) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>api_url</code></td> <td> <p>GitHub API URL. Defaults to the <code>GITHUB_API_URL</code> environment variable, if set, and otherwise to <a href="https://api.github.com">https://api.github.com</a>.</p> </td></tr> </table> <h3>Value</h3> <p>A string of characters, if a PAT is found, or the empty string, otherwise. For convenience, the return value has an S3 class in order to ensure that simple printing strategies don't reveal the entire PAT. </p> <h3>Examples</h3> <pre> ## Not run: gh_token() format(gh_token()) str(gh_token()) ## End(Not run) </pre> <hr /><div style="text-align: center;">[Package <em>gh</em> version 1.3.1 <a href="00Index.html">Index</a>]</div> </body></html>