Skip to content

GitHub token setup

This guide explains how to create a GitHub Personal Access Token (PAT) for use with glance and kickstart when you’re not using GitHub CLI or browser auth. Set the GITHUB_TOKEN environment variable with your token.

Recommendation: Prefer fine-grained PATs over classic tokens: they are scoped to specific repositories and permissions, reducing risk if the token is exposed.

For normal use, prefer GitHub CLI (gh auth login) or browser auth (dn auth); no PAT or env var needed. Use a PAT when:

  • Running in CI (e.g. GitHub Actions: GITHUB_TOKEN is provided automatically)
  • Running in scripts or headless environments
  • You cannot use gh or browser login

When you do use a PAT, fine-grained tokens are recommended: they limit access to specific repositories and permissions.

The glance and kickstart tools interact with the GitHub API to:

  • Fetch repository information
  • Retrieve issues and commits
  • Create pull requests

These operations require authentication. Personal Access Tokens are supported as a fallback when GitHub CLI or browser auth are not available.

Fine-grained PATs (recommended): Scoped to specific repos and permissions. Create a fine-grained token → choose Repository access (only the repos you need) → under Permissions, set Contents (Read and write), Pull requests (Read and write), Metadata (Read-only). For org repos, add Organization permissions → Members (Read-only) if needed.

Classic PATs: Broader access. Use only when fine-grained tokens don’t fit (e.g. some CI setups).

  1. Go to GitHub.com and sign in
  2. Click your profile picture in the top right corner
  3. Select Settings from the dropdown menu
  1. In the left sidebar, scroll down and click Developer settings
  2. Click Personal access tokens in the left sidebar
  3. Prefer Fine-grained tokens (recommended); or Tokens (classic) if needed

Fine-grained: Use Generate new tokenGenerate new token (fine-grained). Set resource owner, repository access, and permissions (Contents, Pull requests, Metadata; add org Members read if needed).

Classic: Use Generate new tokenGenerate new token (classic). Set:

  • Name (e.g. “dn-kickstart”)
  • Expiration (e.g. 90 days)
  • Scopes: repo (or public_repo) and read:org for organization repos

IMPORTANT: GitHub will only show the token once. Copy it immediately and store it securely.

  1. Copy the generated token (it starts with ghp_)
  2. Store it securely (password manager, encrypted file, etc.)
  3. Never commit this token to version control

Set GITHUB_TOKEN with your token. (dn also accepts the legacy DANGEROUS_GITHUB_TOKEN for backward compatibility.)

Add to your ~/.zshrc or ~/.bashrc:

Terminal window
export GITHUB_TOKEN="ghp_your_token_here"

Then reload your shell:

Terminal window
source ~/.zshrc # or ~/.bashrc
Terminal window
$env:GITHUB_TOKEN="ghp_your_token_here"

To make it persistent, add to your PowerShell profile:

Terminal window
[System.Environment]::SetEnvironmentVariable("GITHUB_TOKEN", "ghp_your_token_here", "User")
Terminal window
echo $GITHUB_TOKEN # macOS/Linux
echo $env:GITHUB_TOKEN # Windows PowerShell

Fine-grained PATs: Repository permissions: Contents (Read and write), Pull requests (Read and write), Metadata (Read-only). For org repos, add Organization permissions → Members (Read-only) if needed.

Classic PATs:

ScopeDescriptionRequired for
repoFull control of private repositoriesPrivate repositories, creating PRs
public_repoAccess public repositoriesPublic repositories only
read:orgRead org and team membershipOrganization repositories

Recommendation: Prefer fine-grained PATs; for classic, minimum is repo (or public_repo) and read:org for org repos.

Best practices:

  1. Never commit tokens to version control — Use environment variables; add GITHUB_TOKEN to .gitignore if storing in a file.
  2. Use token expiration — Set tokens to expire (30–90 days); rotate regularly.
  3. Limit scope — Prefer fine-grained PATs scoped to specific repositories.
  4. Revoke unused tokens — Review and revoke in GitHub Settings.
  5. Use separate tokens — Different tokens for different tools/environments.
  6. Monitor usage — Check GitHub’s security log for unexpected API usage.

”No GitHub token found” or token not used

Section titled “”No GitHub token found” or token not used”
  • Verify the token is set: echo $GITHUB_TOKEN (or echo $env:GITHUB_TOKEN on Windows)
  • Make sure you’ve reloaded your shell after setting the variable
  • dn accepts GITHUB_TOKEN (preferred) or the legacy DANGEROUS_GITHUB_TOKEN

”Repository not found or access denied”

Section titled “”Repository not found or access denied””
  • Verify your token has the correct scopes (repo for private repos)
  • Check that you have access to the repository
  • Ensure the token hasn’t expired
  • Verify the remote URL is correct: git remote get-url origin or sl paths default
  • Ensure the repository exists and you have access
  • Check that your token has the necessary permissions