This guide explains how to use the --issue flag safely, how Copilot SDK auth differs from GitHub API auth, and how to fix 401 errors.
RepoCheckAI uses two separate auth paths:
- Copilot SDK auth (models and analysis)
- If this fails, you will see:
Failed to list models: 401.
- If this fails, you will see:
- GitHub API auth (repo read + issue creation)
- If this fails, you will see 401/403 during repo reads or issue creation.
You must configure both.
Use GitHub CLI to authenticate with OAuth (recommended).
# Start clean
Remove-Item Env:GITHUB_TOKEN, Env:GH_TOKEN -ErrorAction SilentlyContinue
# Login to GitHub CLI
# Choose: GitHub.com -> Login via web -> HTTPS
gh auth logout
gh auth login
# Confirm login
# Active account should be true
# Do NOT use GITHUB_TOKEN here
gh auth status
# Export OAuth token for RepoCheckAI
$env:GH_TOKEN = (gh auth token)If you still see Failed to list models: 401, re-run gh auth login and verify your Copilot subscription is active on that account.
You need a PAT that can create issues in the target repo.
- GitHub -> Settings -> Developer settings
- Personal access tokens -> Tokens (classic)
- Generate new token (classic)
- Scopes:
repo(private + public) orpublic_repo(public only)
- Generate and copy the token once
- GitHub -> Settings -> Developer settings
- Personal access tokens -> Fine-grained tokens
- Repository access:
- All repositories (if you need issue write across your repos)
- or Only select repositories (recommended)
- Repository permissions (minimum):
- Metadata: Read-only (Required)
- Contents: Read-only
- Issues: Read and write
- Account permissions: keep No access
- Generate and copy the token once
You can use Copilot auth (GH_TOKEN) and pass the PAT only for issue creation.
# Copilot SDK auth
$env:GH_TOKEN = (gh auth token)
# Start in dev (chat)
npm run dev:cliIn the app:
/deep owner/repo --issue --token <YOUR_PAT>
Direct mode:
repocheck analyze owner/repo --issue --token <YOUR_PAT>Start both services:
npm run dev:local-uiIn the Web UI form:
- Enable Publish to GitHub Issues
- Optionally fill GitHub Token
- Run analysis
Token behavior in Web UI:
- If GitHub Token is filled, that value is used.
- If the field is empty, the backend tries
GITHUB_TOKENfrom server environment. - If neither is available, analysis still runs, but issue publishing is skipped.
$env:GITHUB_TOKEN = "<YOUR_PAT>"
Invoke-RestMethod -Method Post \
-Headers @{ Authorization = "Bearer $env:GITHUB_TOKEN" } \
-Uri https://api.github.com/repos/owner/repo/issues \
-Body (@{ title = "RepoCheckAI test"; body = "test" } | ConvertTo-Json) \
-ContentType "application/json"- Models 401 -> Copilot auth failed (redo section 2)
- Issue 401 -> PAT missing Issues: Read/Write
- Issue 403 -> PAT valid but no access to that repo
- Never commit tokens or store them inside the repo
- Use short expiration for PATs
- Revoke tokens immediately if exposed