Skip to main content

Module device_flow

Module device_flow 

Source
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:

  1. POST https://github.com/login/device/code → returns a user code + device code + verification URI + polling interval.
  2. Print the user code, open the verification URI in the browser, wait for the user to approve.
  3. Poll POST https://github.com/login/oauth/access_token at 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§

DeviceCodeResponse
DeviceFlowOutcome
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:user is 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 (default https://github.com). Stdout receives the user-facing prompt; stderr is left alone so CI logs stay clean.