Expand description
GitHub Copilot OAuth (device authorization + broker-owned session mint).
Experimental. Device-flow endpoints are official GitHub OAuth. The session-mint
path (GET /copilot_internal/v2/token) is community-observed and is not
documented as a stable general-purpose third-party API. Do not describe it as
officially supported.
Credential mapping:
OAuthCredentials.refresh= long-lived GitHub user token (broker-owned only)OAuthCredentials.access= short-lived Copilot session tokenOAuthCredentials.expires= session expiry (ms, with skew)
The long-lived GitHub token must never be vended, logged, or placed in broker wire types.
Structs§
- Device
Authorization - Injected
Http Response - Minimal HTTP response used by the device-flow / mint state machine.
- Login
Hooks - Session
Token
Enums§
- Copilot
Auth Error - Failures from the Copilot auth chain. Variants intentionally store no device codes, user codes, tokens, or Authorization headers so Display/Debug cannot leak them.
- Device
Poll Outcome - Outcome of one device-token poll (secret-safe; token only on Authorized).
Constants§
- ACCESS_
TOKEN_ URL - Official GitHub OAuth token endpoint (device-code grant).
- CLIENT_
ID - Public native-client id observed in Copilot editor clients (VS Code lineage). Not a client secret. Provenance: community consensus + device-flow examples; not a first-class constant on docs.github.com. See docs/specs/github-copilot-oauth-spec.md.
- CONNECT_
TIMEOUT - Connect timeout for production device/poll/mint HTTP.
- DEFAULT_
VERIFICATION_ URI - Default verification page (official docs.github.com device flow).
- DEVICE_
CODE_ URL - Official GitHub device-authorization endpoint.
- DEVICE_
GRANT_ TYPE - Device-code grant type (RFC 8628).
- MAX_
RESPONSE_ BODY_ BYTES - Maximum response body bytes accepted from device/poll/mint endpoints.
- MINT_
COPILOT_ INTEGRATION_ ID - MINT_
EDITOR_ PLUGIN_ VERSION - MINT_
EDITOR_ VERSION - MINT_
USER_ AGENT - PROVIDER
- Canonical storage / broker / model-prefix id.
- REQUEST_
TIMEOUT - Full request timeout for production device/poll/mint HTTP.
- SCOPE
- Least-privilege scope among common working values (community-observed).
- SESSION_
MINT_ URL - Community-observed Copilot session-mint endpoint (pinned host+path).
Traits§
- Copilot
Browser - Injectable browser opener (production uses
open_browser). - Copilot
Cancel - Injectable cancellation signal for device-flow polling.
- Copilot
Clock - Injectable clock (now + cancellable sleep) for deterministic poll tests.
- Copilot
Http - Injectable HTTP surface so tests never touch the network.
Functions§
- apply_
slow_ down - credentials_
from_ session - login
- Production login entry (real network + system browser + auth.json).
- login_
with - Device start → user prompt → poll → mint → atomic persist.
- mint_
credentials - Build credentials after a successful mint (GitHub token → refresh).
- mint_
session_ token - Exchange a long-lived GitHub user token for a short-lived Copilot session.
- parse_
device_ code_ response - parse_
device_ poll_ response - parse_
session_ mint_ response - poll_
device_ token - One poll against the token endpoint.
- read_
body_ capped - Read a response body with a hard byte cap. Fail closed if exceeded.
- refresh_
token - Broker refresh: re-mint session from stored GitHub user token (no browser).
- session_
mint_ request_ headers - Headers attached only to the pinned session-mint request.
- start_
device_ authorization - Start device authorization (POST device/code).
- validate_
device_ endpoint - Accept only the exact pinned HTTPS github.com device endpoints.
- validate_
session_ mint_ endpoint - Accept only the pinned session-mint host+path (no query, no alternate host).
- validate_
verification_ uri - Accept only the documented GitHub device verification destination:
https://github.com/login/deviceoptionally with a singleuser_codequery (verification_uri_complete). Rejects userinfo, fragments, alternate ports, deceptive paths, and arbitrary query keys. - wait_
for_ device_ authorization - Poll until authorized, denied, expired, cancelled, or deadline.