Skip to content

Redeem a device code for an API key (RFC 8628 token endpoint)

POST
/v1/oauth/token
curl --request POST \
--url https://api.legesher.io/v1/oauth/token \
--header 'Content-Type: application/json' \
--data '{ "client_id": "example", "device_code": "example", "grant_type": "urn:ietf:params:oauth:grant-type:device_code" }'

Poll for approval; on success the access token is a fresh API key.

Poll outcomes (HTTP 400, OAuth error body): authorization_pending (keep polling), slow_down (add 5 seconds to the interval; a poll that comes too early also restarts the wait), expired_token / access_denied (terminal: restart the flow), invalid_grant (unknown, malformed, or already-redeemed code).

object
client_id

Accepted and ignored: there is no client registry.

string
device_code
required

The device_code from POST /v1/oauth/device.

string
grant_type
required

Must be the RFC 8628 device-code grant URN.

string
Allowed values: urn:ietf:params:oauth:grant-type:device_code

Successful Response

Media type application/json
TokenResponse

RFC 6749 §5.1 access-token response (successful device redemption).

The access token is a newly created Legesher API key: use it as Authorization: Bearer <token> like any other key. It does not expire and there is no refresh token; revoke it with POST /v1/oauth/revoke.

object
access_token
required
Access Token

A newly minted API key (lgsh_live_…). Shown exactly once.

string
token_type
Token Type

Always ‘bearer’.

string
default: bearer
Allowed value: bearer

Example

{
"token_type": "bearer"
}
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.