GitHub API

Set up a personal access token for the GitHub API.

⏱ 3 minutes developer-tools git github.com
getapi github

Prerequisites

  • A GitHub account

Credentials

Variable Description Sensitive
GITHUB_TOKEN Personal access token (fine-grained or classic) Secret

Setup Steps

  1. 1 Info

    We'll create a GitHub personal access token. GitHub recommends fine-grained tokens for new projects, but classic tokens are simpler.

  2. 2 Choice

    Which type of token do you want?

  3. 3 Open URL

    Opening the fine-grained token creation page.

    https://github.com/settings/personal-access-tokens/new
  4. 4 Info

    Give the token a descriptive name and set an expiration. token_note

  5. 5 Input

    Copy your new token and paste it here:

    → GITHUB_TOKEN
    At least 20 characters
  6. 6 Validate

    Checking your token works...

    Token verified. You're all set.
    Couldn't verify the token. Make sure it hasn't expired and has the necessary permissions.
  7. 7 Open URL

    Opening the classic token creation page.

    https://github.com/settings/tokens/new
  8. 8 Info

    Give the token a descriptive name and set an expiration. token_note

  9. 9 Input

    Copy your new token and paste it here:

    → GITHUB_TOKEN
    At least 20 characters
  10. 10 Validate

    Checking your token works...

    Token verified. You're all set.
    Couldn't verify the token. Make sure it hasn't expired and has the necessary permissions.

Things to Know

  • Tokens are only shown once when created. Store them immediately.
  • Fine-grained tokens can be scoped to specific repositories — classic tokens apply to your entire account.
  • Set an expiration date. Tokens without expiry are a security risk.
  • For GitHub Actions, use repository secrets instead of personal access tokens.