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

# Get Token

> Exchange an authorization code for tokens using the Authorization Code Flow.

## Endpoint

`POST /oauth/token`

For token-based authentication, use the `oauth/token` endpoint to get an access token for your application to make authenticated calls to a secure API. Optionally, you can also retrieve an ID Token and a Refresh Token. ID Tokens contain user information in the form of scopes you application can extract to provide a better user experience. Refresh Tokens allow your application to request a new access token once the current token expires without interruping the user experience. To learn more, read [ID Tokens](https://auth0.com/docs/secure/tokens/id-tokens) and [Refresh Tokens](https://auth0.com/docs/secure/tokens/refresh-tokens).

Note that the only OAuth 2.0 flows that can retrieve a Refresh Token are:

* [Authorization Code Flow (Authorization Code)](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow)
* [Authorization Code Flow with PKCE (Authorization Code with PKCE)](https://auth0.com/docs/get-started/authentication-and-authorization-flow/authorization-code-flow-with-pkce)
* [Resource Owner Password](https://auth0.com/docs/get-started/authentication-and-authorization-flow/resource-owner-password-flow)
* [Device Authorization Flow](https://auth0.com/docs/get-started/authentication-and-authorization-flow/device-authorization-flow)
* Token Exchange\*

This is the flow that regular web apps use to access an API. Use this endpoint to exchange an Authorization Code for a token.

## 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 you are using. For Authorization Code, use `authorization_code`.

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

Your application's Client ID.

**client\_secret** `string` *required*

Your application's Client Secret.

**code** `string` *required*

The Authorization Code received from the initial `/authorize` call.

**redirect\_uri** `string`

This is required only if it was set at the [GET /authorize](#authorization-code-grant) endpoint. The values from `/authorize` must match the value you set at `/oauth/token`.

## Response Schema

\{}

application/json

**access\_token** `string`

The access token.

**refresh\_token** `string`

The refresh 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.

## Agent access tokens

> [!WARNING]
>
> **The Agent as Principal feature is in [Early Access](/docs/docs/troubleshoot/product-lifecycle/product-release-stages).**
>
> To participate, contact Auth0 Support.
>
> By using this feature, you agree to the applicable Free Trial terms in Okta's [Master Subscription Agreement](https://www.okta.com/legal).

When the application exchanging the authorization code is linked to an agent and agent subject claims are enabled for the target API, the issued access token records the agent as the actor on the user's behalf:

* The `sub` claim remains the user identifier. The agent identity surfaces in the `act` claim, not in `sub`.
* The `act` claim identifies the agent: `{ "sub": "agt_72jbvv7LfRKYp59gtRLtkn", "sub_profile": "ai_agent", "client_id": "YOUR_CLIENT_ID", "iss": "https://YOUR_DOMAIN/" }`.
* The token includes `sub_profile: "user"` and `client_profile` with an `ai_agent` suffix, for example `web_app ai_agent`.

If the access token already carries an actor from a session transfer or an On-Behalf-Of token exchange, that actor takes precedence and no agent actor is added. These claims apply to the access token only; the ID token is unaffected. The response object schema is unchanged. To learn more, read [Access Token Profiles](/docs/docs/secure/tokens/access-tokens/access-token-profiles#claims).

## Response Messages

| Status | Description |
| - | - |
| 200 | Successful token retrieval |
