Copilot uses GitHub OAuth device flow authentication.
-
Stored OAuth token (preferred)
- Captured via device flow authentication
- Stored at:
%APPDATA%/UsageBar/copilot-token.json
-
Environment variable (fallback)
GITHUB_TOKENenvironment variable
-
GitHub CLI (fallback)
- Reads token from
gh auth status
- Reads token from
GitHub OAuth Device Flow:
- Request device code from
POST https://github.com/login/device/code - Display code to user (e.g.,
ABCD-1234) - User enters code at
https://github.com/login/device - Poll
POST https://github.com/login/oauth/access_tokenuntil authorized - Store token for future use
| Endpoint | Purpose |
|---|---|
GET https://api.github.com/copilot_internal/user |
Usage quotas + plan info |
Authorization: token <github_token>
Accept: application/json
Editor-Version: vscode/1.96.2
Editor-Plugin-Version: copilot-chat/0.26.7
User-Agent: GitHubCopilotChat/0.26.7
X-Github-Api-Version: 2025-04-01
| Field | Source |
|---|---|
| Primary usage | quota_snapshots.premiumInteractions percent |
| Secondary usage | quota_snapshots.chat percent |
| Plan | copilot_plan |
| Field | Source |
|---|---|
| Primary | monthly_quotas.completions (e.g., "4000/mo") |
| Secondary | monthly_quotas.chat (e.g., "500/mo") |
| Reset date | limited_user_reset_date |
src/main/providers/copilot.ts- Provider implementation- Token stored in
%APPDATA%/UsageBar/copilot-token.json