---
title: Device code
description: Exchange a device code for access and refresh tokens during the CLI Auth flow.
descriptions:
  device_code_request:
    grant_type: >-
      Must be `urn:ietf:params:oauth:grant-type:device_code` for device
      authorization flow.
    device_code: The device code obtained from the device authorization endpoint.
    client_id: The WorkOS client ID for your application.
  device_code_response:
    access_token: The access token for making authenticated requests.
    refresh_token: The refresh token for obtaining new access tokens.
    token_type: 'The token type, always "Bearer".'
    expires_in: The lifetime of the access token in seconds.
reference:
  curl:
    - key: device-code
      id: device_code_exchange
      url: /reference/authkit/cli-auth/device-code
      title: /user_management/authenticate
      type: POST
      parameters:
        - key: grant_type
          type: '"urn:ietf:params:oauth:grant-type:device_code"'
          description: (device_code_request.grant_type)
        - key: device_code
          type: string
          description: (device_code_request.device_code)
        - key: client_id
          type: string
          description: (device_code_request.client_id)
      returns:
        - key: access_token
          type: string
          description: (device_code_response.access_token)
        - key: refresh_token
          type: string
          description: (device_code_response.refresh_token)
        - key: token_type
          type: '"Bearer"'
          description: (device_code_response.token_type)
        - key: expires_in
          type: integer
          description: (device_code_response.expires_in)
originalPath: >-
  .tmp-workos-clone/packages/docs/content/reference/authkit/cli-auth/device-code.mdx
---

## Device code

Exchanges a device code for access and refresh tokens as part of the [CLI Auth](/authkit/cli-auth) flow. This endpoint should be polled repeatedly until the user authorizes the request, declines it, or the device code expires.

<CodeBlock referenceId="device_code_exchange">
  <CodeBlockTab title="Request" file="device-code-request" />
  <CodeBlockTab title="Response" file="device-code-response" />
</CodeBlock>
