docs/copilot.md
Copilot uses GitHub OAuth device flow and the Copilot internal usage API for primary usage. Optional budget extras use GitHub web cookies only when enabled.
GitHub OAuth device flow (user initiated)
POST https://github.com/login/device/codePOST https://github.com/login/oauth/access_tokenenterpriseHost in ~/.codexbar/config.json or the provider settings UIhttps://octocorp.ghe.com/login to octocorp.ghe.comhttps://<enterpriseHost>/login/...read:user.~/.codexbar/config.json → providers[].apiKey for copilotproviders[].tokenAccountsUsage fetch
GET https://api.github.com/copilot_internal/userapi.<enterpriseHost>.Authorization: token <github_oauth_token>Accept: application/jsonEditor-Version: vscode/1.96.2Editor-Plugin-Version: copilot-chat/0.26.7User-Agent: GitHubCopilotChat/0.26.7X-Github-Api-Version: 2025-04-01Budget fetch (optional GitHub web endpoint, best-effort)
GET https://github.com/settings/billing/budgets?page=<page>&page_size=10&scope=customerCookie: <github.com browser cookies>Accept: application/jsonX-Requested-With: XMLHttpRequestGitHub-Verified-Fetch: trueX-Fetch-Nonce: <fresh nonce when available>https://github.com/settings/billing/budgets, then calls the JSON
endpoint. If GitHub rejects the web request, CodexBar keeps the normal Copilot quota bars and omits budget bars.quotaSnapshots.premiumInteractions percent remaining → used percent.quotaSnapshots.chat percent remaining → used percent.extraRateWindows, only when "Budget extras"
is enabled.
copilotcopilot_premium_request, copilot_agent_premium_request, spark_premium_requestcopilotPlan.Sources/CodexBarCore/Providers/Copilot/CopilotUsageFetcher.swiftSources/CodexBarCore/Providers/Copilot/CopilotDeviceFlow.swiftSources/CodexBar/Providers/Copilot/CopilotLoginFlow.swiftSources/CodexBar/CopilotTokenStore.swift (legacy migration helper)