Skip to main content

Module device

Module device 

Source
Expand description

OAuth device flow implementation.

Implements the GitHub OAuth device flow as described in https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/authorizing-oauth-apps#device-flow.

The flow:

  1. Request a device code from POST /login/device/code
  2. Show the user a one-time code and URL
  3. Poll POST /login/oauth/access_token until the user completes authorization
  4. Return the access token

Structs§

AccessTokenResponse
Response from POST /login/oauth/access_token (success).
DeviceCodeResponse
Response from POST /login/device/code.

Functions§

display_instructions
Display the device activation instructions to the user.
poll_for_token
Poll for the access token until the user completes authorization or the flow times out.
request_device_code
Request a device code from GitHub.