Next: , Previous: , Up: GitHub API Authentication   [Index]


1.1.2 GitHub API Authentication—Personal Access Tokens

You can create a new Personal Access Token at:

Fill in the form and then move to the next screen, which will show you the token. Copy it somewhere safe; you will never be able to see it again.

You can now use the token from the command line with curl:

curl --header "Authorization: token d64761df071c2bf517ceb063b279432ed2f89c62" \
    https://api.github.com/repos/octokit/core.js/releases/latest

Or with fetch in a browser or node-fetch in Node.js:

const response = await fetch(
  "https://api.github.com/repos/octokit/core.js/releases/latest", 
  {
    headers: {
      authorization: "token d64761df071c2bf517ceb063b279432ed2f89c62"
    }
  }
)
console.log(await response.json());