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

# Exchange Authorization Code for Token

> Exchange an authorization code for an access token after the user is redirected back to your callback.

## Endpoint

`POST /oauth/token`

When users are redirected back to your callback, you need to make a `POST` call to the `oauth/token` endpoint to exchange an authorization code for an access and/or an ID token.

### Remarks

To make a call to the `/oauth/token` endpoint, you must:

* Set the request content type as `application/x-www-form-urlencoded`
* Use `strings` for all passed parameters
* Include an additional parameter for application authentication in the request (e.g. `client_secret`, or `client_assertion` and `client_assertion_type` for JSON Web Token Client Authentication, or pass a `client-certificate` and `client-certificate-ca-verified` header when using Mutual TLS).

## Headers

**DPoP** `string`

A DPoP proof for the request. This is optional and only required if your application uses Demonstrating Proof-of-Possession.

## Body Parameters

The request body is in `application/x-www-form-urlencoded` format.

**grant\_type** `string` *required*

Denotes the flow; use `authorization_code` with a valid authorization code.

**code** `string`

The authorization code from the initial `/authorize` call.

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

The `client_id` of your application. Required.

**request\_uri** `string`

This is required only if set at the `GET` `/oauth/par` endpoint.

**code\_verifier** `string`

Cryptographically random key used to generate the `code_challenge`. Recommended if `code_challenge` was provided.

## Response Schema

\{}

application/json

**access\_token** `string`

The access token to access protected resources.

**refresh\_token** `string`

Token used to obtain new access tokens.

**id\_token** `string`

The ID token.

**token\_type** `string`

The type of token. Usually `Bearer`.

**expires\_in** `integer`

The access token lifetime in seconds.

## Response Messages

| Status | Description |
| - | - |
| 200 | Successful response containing the tokens. |
