> ## Documentation Index
> Fetch the complete documentation index at: /docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Authorize Device

> Obtain a device code to start the Device Authorization Flow for input-constrained devices.

## Endpoint

`POST /oauth/device/code`

This flow is designed for input-constrained devices to access an API. Use this endpoint to obtain a device code that allows the user to authorize the device.

## Request Example

```http theme={null}
POST https://{yourDomain}/oauth/device/code
Content-Type: application/x-www-form-urlencoded

client_id=${account.clientId}&scope=SCOPE&audience=API_IDENTIFIER
```

### Response Values

| Value | Description |
| :- | :- |
| `device_code` | The unique code for the device. |
| `user_code` | The code the user must input to authorize the device. |
| `verification_uri` | The URL the user should visit to authorize the device. |
| `verification_uri_complete` | The complete URL including the user code for easy access. |
| `expires_in` | The lifetime of the device and user codes in seconds. |
| `interval` | The polling interval in seconds to request a token. |

### Remarks

* Include `offline_access` in the `scope` to obtain a Refresh Token.
* Use the returned device code to request an access token from the token endpoint.

### Token Request Example

```http theme={null}
POST https://{yourDomain}/oauth/token
Content-Type: application/x-www-form-urlencoded

client_id=${account.clientId}&device_code=YOUR_DEVICE_CODE&grant_type=urn:ietf:params:oauth:grant-type:device_code
```

### Responses

#### 200

A successful request returns an access token.

```json theme={null}
HTTP/1.1 200 OK
Content-Type: application/json
{
   "access_token": "eyJz93a...k4laUWw",
   "id_token": "eyJ...0NE",
   "refresh_token": "eyJ...MoQ",
   "expires_in": 86400,
   "token_type": "Bearer"
}
```

### Error Responses

```json theme={null}
HTTP/1.1 403 Forbidden
Content-Type: application/json
{ "error": "authorization_pending", "error_description": "User has yet to authorize device code." }
```

```json theme={null}
HTTP/1.1 429 Too Many Requests
Content-Type: application/json
{ "error": "slow_down", "error_description": "You are polling faster than the specified interval of 5 seconds." }
```

```json theme={null}
HTTP/1.1 403 Forbidden
Content-Type: application/json
{ "error": "access_denied", "error_description": "User cancelled the confirmation prompt." }
```

### Learn More

* [Device Authorization Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow)
* [Call API using the Device Authorization Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow/call-your-api-using-the-device-authorization-flow)
* [Setting up a Device Code Grant using the Management Dashboard](https://auth0.com/docs/get-started/applications/update-grant-types)

## Body Parameters

**client\_id** `string` *required*

Your application's ID.

**scope** `string`

The scopes for which you want to request authorization.

**audience** `string`

The unique identifier of the target API you want to access.

**resource** `string`

The identifier of the target API (resource server) you want to access. Must match an API Identifier registered in your Auth0 tenant. Used as an alternative to `audience` when the tenant's [Resource Parameter Compatibility Profile](https://auth0.com/docs/get-started/tenant-settings#settings-advanced) is set to `compatibility`.

## Response Schema

\{}

application/json

**device\_code** `string`

The unique code for the device. When the user goes to the `verification_uri` in their browser-based device, this code is bound to their session.

**user\_code** `string`

The code that the user must input at the `verification_uri`.

**verification\_uri** `string`

The URL the user must visit to authorize the device.

**verification\_uri\_complete** `string`

The complete URL the user must visit, including the `user_code`.

**expires\_in** `integer`

The lifetime in seconds of the `device_code` and `user_code`.

**interval** `integer`

The interval in seconds at which the app should poll for a token.

## Response Messages

| Status | Description |
| - | - |
| 200 | Returns device and user codes. |
