Skip to Content
Documentation

Device sign-in

RFC 8628 device authorization grant for CLIs and TVs.

/device/code

POST
/device/code

Request a device and user code

Follow rfc8628#section-3.2

Request Body

application/json
  1. body
client_id?string
user_id?string

The user ID to which the device code should be pre-bound.

scope?string

Space-separated list of scopes

client_secret?string

OAuth client secret

client_assertion?string

OAuth client assertion

client_assertion_type?string

OAuth client assertion type

resource?|array<string>|

RFC 8707 resource indicator(s) to bind to this authorization request

Response Body

Success

application/json
  1. response
device_code?string

The device verification code

user_code?string

The user code to display

verification_uri?string

The URL for user verification. Defaults to /device if not configured.

Formaturi
verification_uri_complete?string

The complete URL with user code as query parameter.

Formaturi
expires_in?number

Lifetime in seconds of the device code

interval?number

Minimum polling interval in seconds

Example Request
curl -X POST 'https://auth.example.com/api/auth/device/code' \  -H 'Content-Type: application/json' \  -d '{}'
Example Response
{  "device_code": "string",  "user_code": "string",  "verification_uri": "http://example.com",  "verification_uri_complete": "http://example.com",  "expires_in": 0,  "interval": 0}

/device/token

POST
/device/token

Exchange device code for access token

Follow rfc8628#section-3.4

Request Body

application/json
  1. body
grant_type*"urn:ietf:params:oauth:grant-type:device_code"

The grant type for device flow

Value in"urn:ietf:params:oauth:grant-type:device_code"
device_code*string

The device verification code

client_id*string

The client ID of the application

Response Body

Success

application/json
  1. response
session?
user?
Example Request
curl -X POST 'https://auth.example.com/api/auth/device/token' \  -H 'Content-Type: application/json' \  -d '{  "grant_type": "urn:ietf:params:oauth:grant-type:device_code",  "device_code": "string",  "client_id": "string"}'
Example Response
{  "session": {    "id": "string",    "expiresAt": "2019-08-24T14:15:22Z",    "token": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "ipAddress": "string",    "userAgent": "string",    "userId": "string",    "impersonatedBy": "string",    "activeOrganizationId": "string"  },  "user": {    "id": "string",    "name": "string",    "email": "string",    "emailVerified": false,    "image": "string",    "createdAt": "2019-08-24T14:15:22Z",    "updatedAt": "2019-08-24T14:15:22Z",    "role": "string",    "banned": false,    "banReason": "string",    "banExpires": "2019-08-24T14:15:22Z",    "username": "string",    "displayUsername": "string",    "twoFactorEnabled": false  }}

/device

GET
/device

Verify user code and get device authorization status

Query Parameters

user_code?string

The user code to verify

Response Body

Device authorization status

application/json
  1. response
user_code?string

The user code to verify

status?string

Current status of the device authorization

Value in"pending""approved""denied"
client_id?string

The client requesting authorization, returned only to the authenticated user who owns this request

scope?string

The requested scopes, returned only to the authenticated user who owns this request

resource?|array<string>

The requested resource indicators, returned only to the authenticated user who owns this request

Example Request
curl -X GET 'https://auth.example.com/api/auth/device'
Example Response
{  "user_code": "string",  "status": "pending",  "client_id": "string",  "scope": "string",  "resource": "string"}

/device/approve

POST
/device/approve

Approve device authorization

Request Body

application/json
  1. body
userCode*string

The user code to approve

Response Body

Success

application/json
  1. response
success?boolean
Example Request
curl -X POST 'https://auth.example.com/api/auth/device/approve' \  -H 'Content-Type: application/json' \  -d '{  "userCode": "string"}'
Example Response
{  "success": true}

/device/deny

POST
/device/deny

Deny device authorization

Request Body

application/json
  1. body
userCode*string

The user code to deny

Response Body

Success

application/json
  1. response
success?boolean
Example Request
curl -X POST 'https://auth.example.com/api/auth/device/deny' \  -H 'Content-Type: application/json' \  -d '{  "userCode": "string"}'
Example Response
{  "success": true}