Skip to content

Start a device sign-in (RFC 8628 device authorization)

POST
/v1/oauth/device
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.

object
client_id

Accepted and ignored: there is no client registry.

string
scope

Accepted and ignored.

string

Example generated

{
"client_id": "example",
"scope": "example"
}

Successful Response

Media type application/json
DeviceAuthorizationResponse

RFC 8628 §3.2 device-authorization response.

object
device_code
required
Device Code

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.

string
expires_in
required
Expires In

Lifetime of the code pair in seconds (then expired_token).

integer
interval
required
Interval

Minimum seconds the device must wait between token polls. Polling faster answers slow_down and restarts the wait.

integer
user_code
required
User Code

The short code the user enters on the verification page, formatted XXXX-XXXX. Case-insensitive; hyphens and spaces are ignored on entry.

string
verification_uri
required
Verification Uri

Where the user goes to approve or deny the sign-in.

string
verification_uri_complete
required
Verification Uri Complete

Verification_uri with the user_code pre-filled, for QR codes and clickable links.

string

Example generated

{
"device_code": "example",
"expires_in": 1,
"interval": 1,
"user_code": "example",
"verification_uri": "example",
"verification_uri_complete": "example"
}
X-Request-ID
string

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.

Media type application/json
OAuthErrorResponse

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
error
required
Error

The OAuth error code (a bare string).

string
error_description
Error Description

Human-readable detail for developers.

Any of:
string

Example generated

{
"error": "example",
"error_description": "example"
}
X-Request-ID
string

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.

Media type application/json
ErrorResponse

Envelope for every error response.

object
error
required
ErrorDetail

Machine-readable code + human message for one error.

object
code
required
Code

Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.

string
details
Details

Per-field breakdown (validation errors only).

Any of:
Array<object>
FieldIssue

One request-validation problem, stripped of the submitted input.

object
field
required
Field

Dotted location of the offending field.

string
message
required
Message

Human-readable description.

string
type
required
Type

Pydantic error type identifier.

string
message
required
Message

Human-readable explanation.

string

Example generated

{
"error": {
"code": "example",
"details": [
{
"field": "example",
"message": "example",
"type": "example"
}
],
"message": "example"
}
}
X-Request-ID
string

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.

Media type application/json
ErrorResponse

Envelope for every error response.

object
error
required
ErrorDetail

Machine-readable code + human message for one error.

object
code
required
Code

Machine-readable error code, e.g. ‘validation_error’, ‘unsupported_language’, ‘language_pack_not_found’, ‘payload_too_large’, ‘foundation_unavailable’, ‘invalid_source_code’, ‘internal_error’.

string
details
Details

Per-field breakdown (validation errors only).

Any of:
Array<object>
FieldIssue

One request-validation problem, stripped of the submitted input.

object
field
required
Field

Dotted location of the offending field.

string
message
required
Message

Human-readable description.

string
type
required
Type

Pydantic error type identifier.

string
message
required
Message

Human-readable explanation.

string

Example generated

{
"error": {
"code": "example",
"details": [
{
"field": "example",
"message": "example",
"type": "example"
}
],
"message": "example"
}
}
X-Request-ID
string

Correlation id for this request: the validated inbound X-Request-ID when one was sent, else a server-minted UUID.