Start a device sign-in (RFC 8628 device authorization)
const url = 'https://api.legesher.io/v1/oauth/device';const options = { method: 'POST', headers: {'Content-Type': 'application/json'}, body: '{"client_id":"example","scope":"example"}'};
try { const response = await fetch(url, options); const data = await response.json(); console.log(data);} catch (error) { console.error(error);}curl --request POST \ --url https://api.legesher.io/v1/oauth/device \ --header 'Content-Type: application/json' \ --data '{ "client_id": "example", "scope": "example" }'Mint a device_code/user_code pair for one sign-in attempt.
Show user_code to the user and send them to verification_uri;
poll POST /v1/oauth/token with device_code every interval
seconds until approval. The user approves the sign-in on the app’s
device page at verification_uri.
Request Body
Section titled “ Request Body ”object
Accepted and ignored: there is no client registry.
Accepted and ignored.
Example generated
{ "client_id": "example", "scope": "example"}object
Accepted and ignored: there is no client registry.
Accepted and ignored.
Example generated
client_id=example&scope=exampleResponses
Section titled “ Responses ”Successful Response
RFC 8628 §3.2 device-authorization response.
object
The device verification code (lgsh_device_…). A bearer secret: hold it privately and present it only to the token endpoint. Never shown to the user.
Lifetime of the code pair in seconds (then expired_token).
Minimum seconds the device must wait between token polls. Polling faster answers slow_down and restarts the wait.
The short code the user enters on the verification page, formatted XXXX-XXXX. Case-insensitive; hyphens and spaces are ignored on entry.
Where the user goes to approve or deny the sign-in.
Verification_uri with the user_code pre-filled, for QR codes and clickable links.
Example generated
{ "device_code": "example", "expires_in": 1, "interval": 1, "user_code": "example", "verification_uri": "example", "verification_uri_complete": "example"}Headers
Section titled “ Headers ”Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.
OAuth error (RFC 6749 §5.2 / RFC 8628 §3.5): authorization_pending, slow_down, expired_token, access_denied, invalid_grant, invalid_request, or unsupported_grant_type.
RFC 6749 §5.2 / RFC 8628 §3.5 error body (HTTP 400).
error values used by this API: authorization_pending,
slow_down, expired_token, access_denied, invalid_grant,
invalid_request, unsupported_grant_type.
object
Example generated
{ "error": "example", "error_description": "example"}Headers
Section titled “ Headers ”Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.
Request body over the ceiling.
Envelope for every error response.
object
Machine-readable code + human message for one error.
object
Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.
Per-field breakdown (validation errors only).
One request-validation problem, stripped of the submitted input.
object
Dotted location of the offending field.
Human-readable description.
Pydantic error type identifier.
Human-readable explanation.
Example generated
{ "error": { "code": "example", "details": [ { "field": "example", "message": "example", "type": "example" } ], "message": "example" }}Headers
Section titled “ Headers ”Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.
Too many requests. Wait before retrying.
Envelope for every error response.
object
Machine-readable code + human message for one error.
object
Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.
Per-field breakdown (validation errors only).
One request-validation problem, stripped of the submitted input.
object
Dotted location of the offending field.
Human-readable description.
Pydantic error type identifier.
Human-readable explanation.
Example generated
{ "error": { "code": "example", "details": [ { "field": "example", "message": "example", "type": "example" } ], "message": "example" }}Headers
Section titled “ Headers ”Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.