CopilotTokenManager
Category: Providers
Source: copilot_token_manager.dart
Exchanges long-lived GitHub OAuth tokens for short-lived Copilot tokens, caches the result in [CredentialStore], and refreshes on expiry.
GitHub Copilot issues a ~30-minute token that authorizes requests against api.githubcopilot.com. This module is the single source of truth for "give me a valid Copilot bearer" — every LLM request funnels through it.
Classes
abstract CopilotFields
Field keys stored under providers.copilot in credentials.json.
Properties
| Property | Type | Description |
|---|---|---|
githubToken | const | |
copilotToken | const | |
expiresAt | const |
CopilotAuthException
Constructor
dart
CopilotAuthException(this.message)Properties
| Property | Type | Description |
|---|---|---|
message | String |
Methods
String toString()
CopilotTokenExchange
Constructor
dart
const CopilotTokenExchange({required this.token, required this.expiresAt})Properties
| Property | Type | Description |
|---|---|---|
token | String | |
expiresAt | DateTime |
Functions
`Future<CopilotTokenExchange> exchangeGithubTokenForCopilotToken(
String githubToken, { http.Client? client, })`
POST the Copilot token endpoint with the user's GitHub token. Returns the short-lived Copilot bearer plus its expiry timestamp.
Constants
| Name | Type | Description |
|---|---|---|
copilotClientId | String | Matches OpenCode / VS Code / LiteLLM / copilot-api. It's the public GitHub OAuth app id for the Copilot CLI; everyone uses it. |