Overview
Claude Code Copilot uses GitHub’s OAuth device code flow to authenticate with your GitHub Copilot subscription. This is the same authentication method used by VS Code and other official GitHub tools.No Anthropic API key required — The authentication process only connects to GitHub. Your Copilot subscription provides access to Claude models.
Authentication flow
The authentication process follows GitHub’s secure device code flow:Initiate device code flow
The auth script requests a device code from GitHub’s OAuth server:
scripts/auth.mjs
Display user code
You’ll see a unique code in your terminal:The browser opens automatically on macOS, Windows, and Linux.
Authorize in browser
In your browser:
- Enter the displayed code
- Review the requested permissions (read:user)
- Click “Authorize” to grant access
Poll for access token
The script polls GitHub’s token endpoint until you complete authorization:
scripts/auth.mjs
Running authentication
Authenticate with GitHub by running the auth script:Credential storage
Authentication credentials are stored locally in a JSON file: Default location:COPILOT_AUTH_FILE environment variable:
Token verification
The auth script verifies your token by checking:-
GitHub API access:
scripts/auth.mjs
-
Copilot API access:
scripts/auth.mjs
Re-authentication
If you need to re-authenticate (e.g., token expired or revoked):The auth script automatically detects existing credentials. If valid, it will skip re-authentication and display your current GitHub username.
Troubleshooting
401 Unauthorized errors from Copilot API
401 Unauthorized errors from Copilot API
Device code expired
Device code expired
If you don’t authorize within the time limit (usually 15 minutes), the device code expires:Simply run the auth script again to get a new code.
Authorization denied
Authorization denied
No active Copilot subscription
No active Copilot subscription
Ensure you have an active GitHub Copilot subscription:
- Go to github.com/settings/copilot
- Verify your subscription status
- Purchase or enable Copilot if needed
Browser doesn't open automatically
Browser doesn't open automatically
If the browser doesn’t open:
- Copy the URL from the terminal output
- Manually open it in your browser
- Enter the displayed code
Security considerations
Token scope
The auth flow only requests
read:user scope — the minimum needed to identify your accountLocal storage
Credentials are stored locally on your machine, never sent to third parties
No data logging
The proxy doesn’t log or store any request data or API responses
Revocation
Revoke access anytime at github.com/settings/applications
Next steps
Docker setup
Deploy the proxy as a persistent Docker container with automatic restarts