Expand description
GitHub OAuth Device Flow client.
Reference: https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#device-flow
Three steps:
POST https://github.com/login/device/code→ returns a user code + device code + verification URI + polling interval.- Print the user code, open the verification URI in the browser, wait for the user to approve.
- Poll
POST https://github.com/login/oauth/access_tokenat the advertised interval until the server either returns an access token, a terminal error (access_denied,expired_token), or we exceed the code expiry.
Device Flow is a public-client protocol — no client secret exists. The client ID is the one registered for the registry’s GitHub OAuth App.
Structs§
- Device
Code Response - Device
Flow Outcome - Result of a successful flow.
Constants§
- MEMSTEAD_
GITHUB_ CLIENT_ ID - GitHub OAuth App client ID for memstead.io. Public; safe to commit.
- MEMSTEAD_
GITHUB_ SCOPE - Scope requested at authorization time.
read:useris the minimum the registry needs to resolve the username; asking for more would scare users off in the GitHub approval screen.
Functions§
- open_
browser - Best-effort browser open. Returns whether the open-command launched without immediate failure. Never panics; the printed URL + code remain actionable if this fails.
- run
- Run the device flow end-to-end against the host in
MEMSTEAD_GITHUB_HOST(defaulthttps://github.com). Stdout receives the user-facing prompt; stderr is left alone so CI logs stay clean.