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

# Cross App Access (XAA) with Token Vault

> Configure Token Vault to use Cross App Access (XAA) to store and reuse access tokens your application retrieves via XAA on a user's behalf.

> [!WARNING]
>
> **The Cross App Access (XAA) for the Requesting App feature is in [Early Access](/docs/docs/troubleshoot/product-lifecycle/product-release-stages).**
>
> This feature is available for [Enterprise, B2B Pro, and B2B Essential plans](https://auth0.com/pricing).
>
> By using this feature, you agree to the applicable Free Trial terms in Okta's [Master Subscription Agreement](https://www.okta.com/legal).

[Cross App Access (XAA)](https://datatracker.ietf.org/doc/draft-ietf-oauth-identity-assertion-authz-grant/) allows IT admins in an enterprise setting to centrally manage app-to-app and agent-to-app connections. Token Vault works with XAA to securely store and reuse the access tokens your application retrieves from a third-party API on a user's behalf.

With Token Vault, your application can exchange an Auth0 refresh token for a stored third-party access token in a single call without requiring the user to go through an OAuth 2.0 consent flow. Instead, that access is mediated by a centralized identity provider (IdP) that is trusted by both your organization and the third-party API. To learn more about XAA in Auth0, read [Cross App Access](/docs/docs/ai-agents-mcp/cross-app-access).

**If you want to build and test the full XAA flow from the Requesting App side**: Complete [Environment Setup](/docs/docs/ai-agents-mcp/cross-app-access/requesting-app/set-up-xaa-test-environment) and [Okta as OIDC IdP](/docs/docs/ai-agents-mcp/cross-app-access/requesting-app/idp/okta-as-oidc-idp) first, then return here to [configure your Token Vault application](#configure-your-token-vault-application).

**If you already have Token Vault set up and want to add XAA support**: Skip to [Add XAA to an existing Token Vault integration](#add-xaa-to-an-existing-token-vault-integration).

## What's different with XAA?

1. When using Token Vault with XAA, end users do not need to [connect their account](/docs/docs/secure/call-apis-on-users-behalf/token-vault/connected-accounts-for-token-vault) with external applications. Your application does not need to provide a button to "Connect to \[Third-party Application]" that makes a `POST` request to the My Account API's `/me/v1/connected-accounts/connect` endpoint.
2. The end user needs to authenticate using a federated login with an Okta, OIDC, or SAML connection that is configured for XAA. That connection must be configured as a Requesting App.
3. The third-party API being accessed must support XAA as a Resource App, meaning it can exchange an `ID-JAG` for access tokens.
4. A connection to the third-party application must exist with Connected Accounts for Token Vault and Cross App Access for Token Vault enabled.

## Use Token Vault with a SAML IdP

You can use Token Vault with XAA if your users sign in through a supported SAML IdP. Your IdP must be able to exchange a SAML assertion for a refresh token and issue ID-JAGs. SAML handles sign-in. Token Vault then uses the IdP's OAuth 2.0 token endpoint, which Auth0 finds in the IdP's OpenID Connect metadata.

To set up a SAML connection, read [Configure the Requesting App connection](#configure-the-requesting-app-connection).

## Add XAA to an existing Token Vault integration

If you already have Token Vault set up and want to add XAA support, you need to update two existing connections: the connection your users authenticate with (the Requesting App connection) and the connection to the third-party API (the Resource App connection).

This section covers only the Auth0-side changes needed to enable XAA on existing connections. If you are creating these connections for the first time, or need to configure the Okta side, follow [Okta as OIDC IdP](/docs/docs/ai-agents-mcp/cross-app-access/requesting-app/idp/okta-as-oidc-idp) for the full end-to-end setup.

If your users sign in with SAML, you must also map the SAML Service Provider (SP) Entity ID that Auth0 uses for the connection to the OAuth client that Auth0 uses to authenticate with your IdP. If you skip this step, users can still sign in, but Token Vault requests fail. To learn how, read [Okta as SAML IdP](/docs/docs/ai-agents-mcp/cross-app-access/requesting-app/idp/okta-as-saml-idp).

### Configure the Requesting App connection

The connection your users authenticate with must be configured to request an `ID-JAG` from the enterprise IdP on the user's behalf. This can be an Okta Workforce, OIDC, or SAML connection.

#### Okta or OIDC

> [tab] Auth0 Dashboard
>
> 1. Navigate to **Authentication > Enterprise**, select your connection, and open its settings.
> 2. Under **Credentials**, set **Communication Channel** to **Back Channel**. Token Vault cannot request an ID-JAG using the front channel.
> 3. Under **Settings > Scopes**, add `offline_access`.
> 4. Under **Mappings**, select **Okta Basic** and add `offline_access` to the `userinfo_scope` list in the JSON mapping. Select **Save**.
> 5. Under **Cross App Access > Cross App Access Role**, select **Requesting Application**.
>
> ![](https://mintlify.s3.us-west-1.amazonaws.com/docs-dev/images/xaa/xaa_connection_requesting_app.png)
>
> 6. Select **Save**.

> [tab] Management API
>
> Make a `PATCH` call to the [Update a Connection](/docs/docs/api/management/v2/connections/patch-connections-by-id) endpoint:
>
> ```bash theme={null}
> curl --request PATCH 'https://{yourDomain}/api/v2/connections/{yourConnectionId}' \
>   --header 'Content-Type: application/json' \
>   --header 'Authorization: Bearer <YOUR_MANAGEMENT_API_ACCESS_TOKEN>' \
>   --data '{
>     "cross_app_access_requesting_app": { "active": true },
>     "options": {
>       "scope": "openid profile email offline_access",
>       "type": "back_channel",
>       "attribute_map": {
>         "mapping_mode": "use_map",
>         "userinfo_scope": "openid email profile groups offline_access",
>         "attributes": {
>           "name": "${context.tokenset.name}",
>           "email": "${context.tokenset.email}",
>           "username": "${context.tokenset.preferred_username}",
>           "federated_groups": "${context.userinfo.groups}",
>           "federated_locale": "${context.userinfo.locale}",
>           "federated_zoneinfo": "${context.userinfo.zoneinfo}"
>         }
>       }
>     }
>   }'
> ```
>
> The next time a user signs in using that connection, Token Vault will retain the refresh token and use it to request access to the third-party API.

#### SAML

> [tab] Auth0 Dashboard
>
> 1. Navigate to **Authentication > Enterprise**, select your SAML connection, and open its settings.
> 2. On the **Settings** tab, under **OpenID Connect features**, enter your IdP's URL in **Issuer or discovery URL**, or upload a metadata document.
> 3. Under **Cross App Access Roles**, turn on **Requesting Application**.
> 4. Under **Authentication Settings**, enter the **Client ID** that Auth0 uses to authenticate with your IdP. Then set **Authentication Method** to **Private Key JWT** or **Client Secret**. If you select **Client Secret**, enter the secret under **Credentials**. Select **Save**.
> 5. If you selected **Private Key JWT**, give your IdP the connection's public key, either as a download from **Credentials > Public Keys** or as its JWKS URI. To learn how, read [Private Key JWT Client Authentication](/docs/docs/authenticate/enterprise-connections/private-key-jwt-client-auth).
>
> ![](https://mintlify.s3.us-west-1.amazonaws.com/docs-dev/images/xaa/xaa_connection_saml_requesting_app.png)

> [tab] Management API
>
> 1. To use Private Key JWT, make a `POST` call to the [Create connection keys](/docs/docs/api/management/v2/connections/post-keys) endpoint. Give your IdP the `cert` of the key marked `current`.
>
>    ```bash theme={null}
>    curl --request POST 'https://{yourDomain}/api/v2/connections/{yourConnectionId}/keys' \
>      --header 'Content-Type: application/json' \
>      --header 'Authorization: Bearer <YOUR_MANAGEMENT_API_ACCESS_TOKEN>' \
>      --data '{}'
>    ```
>
> 2. Make a `PATCH` call to the [Update a Connection](/docs/docs/api/management/v2/connections/patch-connections-by-id) endpoint:
>
>    ```bash theme={null}
>    curl --request PATCH 'https://{yourDomain}/api/v2/connections/{yourConnectionId}' \
>      --header 'Content-Type: application/json' \
>      --header 'Authorization: Bearer <YOUR_MANAGEMENT_API_ACCESS_TOKEN>' \
>      --data '{
>        "cross_app_access_requesting_app": { "active": true },
>        "options": {
>          "discovery_url": "https://{yourIdpDomain}/.well-known/openid-configuration",
>          "client_id": "{yourIdpClientId}",
>          "token_endpoint_auth_method": "private_key_jwt"
>        }
>      }'
>    ```
>
> > [!WARNING]
> >
> > The `PATCH` call overrides the connection's entire `options` object. Include the connection's existing `options` in the request.
>
> To use a client secret instead, skip the first step and set `client_secret` in `options` instead of `token_endpoint_auth_method`.

### Configure the Resource App connection

The Resource App connection to the third-party API must be an OIDC connection with both Connected Accounts for Token Vault and Cross App Access for Token Vault enabled.

> [tab] Auth0 Dashboard
>
> 1. Navigate to **Authentication > Enterprise**, select the OIDC connection to the third-party API, and open its settings.
> 2. Under **Purpose**, select **Connected Accounts for Token Vault** or **Authentication and Connected Accounts for Token Vault**.
> 3. Under **Cross App Access**:
>    * Enable **Cross App Access for Token Vault**.
>
> ![](https://mintlify.s3.us-west-1.amazonaws.com/docs-dev/images/xaa/xaa_connection_req_app_tv.png)
>
> 4. Select **Save**.

> [tab] Management API
>
> Make a `PATCH` call to the [Update a Connection](/docs/docs/api/management/v2/connections/patch-connections-by-id) endpoint:
>
> ```bash theme={null}
> curl --request PATCH 'https://{yourDomain}/api/v2/connections/{yourConnectionId}' \
>   --header 'Content-Type: application/json' \
>   --header 'Authorization: Bearer <YOUR_MANAGEMENT_API_ACCESS_TOKEN>' \
>   --data '{
>     "connected_accounts": {
>       "active": true,
>       "cross_app_access": true
>     }
>   }'
> ```

Once you've configured both connections, proceed to [Configure your Token Vault application](#configure-your-token-vault-application) and [test the end-to-end flow](#test-the-end-to-end-flow).

## Configure your Token Vault application

In your Requesting App tenant, create or configure the application that will perform the Token Vault token exchange.

Only confidential, first-party, OIDC-conformant clients can use the Token Vault grant type. Regular Web Applications meet these requirements.

Navigate to **Applications > Applications** and select **Create Application**. Enter a name and select **Regular Web Application**.

> [tab] Auth0 Dashboard
>
> 1. Under **Application URIs**, add your application's callback URL (e.g. `https://localhost:3000/callback`) to **Allowed Callback URLs**.
> 2. Under **Advanced Settings > Grant Types**, enable **Authorization Code**, **Refresh Token**, and **Token Vault**.
> 3. Select **Save Changes**.

> [tab] Management API
>
> Make a `PATCH` call to the [Update a Client](/docs/docs/api/management/v2/clients/patch-clients-by-id) endpoint to add the required grant types and enable Cross App Access:
>
> ```bash theme={null}
> curl --request PATCH 'https://{yourDomain}/api/v2/clients/{clientId}' \
>   --header 'Content-Type: application/json' \
>   --header 'Authorization: Bearer <YOUR_MANAGEMENT_API_ACCESS_TOKEN>' \
>   --data '{
>     "cross_app_access": { "active": true },
>     "grant_types": [
>       "authorization_code",
>       "refresh_token",
>       "urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token"
>     ]
>   }'
> ```

Note the **Client ID** and **Client Secret** of the application. You'll need these when performing the token exchange.

### Enable enterprise connections for the application

If you set up the XAA test environment from the Requesting App side from scratch: You need to enable the OIDC connection you configured in the [Environment Setup](/docs/docs/ai-agents-mcp/cross-app-access/requesting-app/set-up-xaa-test-environment) between your Requesting App tenant and Resource App tenant and the Okta Workforce connection you configured in [Okta as OIDC IdP](/docs/docs/ai-agents-mcp/cross-app-access/requesting-app/idp/okta-as-oidc-idp) for this application.

If you already have Token Vault set up and are adding XAA support: You need to enable the Requesting App connection and Resource App connection for the application you just created. To learn more, read [Add XAA to an existing Token Vault integration](#add-xaa-to-an-existing-token-vault-integration).

> [tab] Auth0 Dashboard
>
> To enable the Requesting App connection:
>
> 1. Navigate to **Authentication > Enterprise**, select the Requesting App connection, and select the **Applications** tab. Then, enable it for the application you just created.
>
> To enable the OIDC connection or the Resource App connection:
>
> 1. Navigate to **Authentication > Enterprise > OpenID Connect (OIDC)**, select the OIDC connection, and select the **Applications** tab. Then, enable it for the application you just created.

> [tab] Management API
>
> Make a `PATCH` call to the [Update a Connection](/docs/docs/api/management/v2/connections/patch-connections-by-id) endpoint for each connection to add the application's `client_id` to the `enabled_clients` array.
>
> For the Requesting App connection:
>
> ```bash theme={null}
> curl --request PATCH 'https://{yourDomain}/api/v2/connections/{requestingAppConnectionId}' \
>   --header 'Content-Type: application/json' \
>   --header 'Authorization: Bearer <YOUR_MANAGEMENT_API_ACCESS_TOKEN>' \
>   --data '{
>     "enabled_clients": ["{yourApplicationClientId}"]
>   }'
> ```
>
> For the OIDC connection:
>
> ```bash theme={null}
> curl --request PATCH 'https://{yourDomain}/api/v2/connections/{oidcConnectionId}' \
>   --header 'Content-Type: application/json' \
>   --header 'Authorization: Bearer <YOUR_MANAGEMENT_API_ACCESS_TOKEN>' \
>   --data '{
>     "enabled_clients": ["{yourApplicationClientId}"]
>   }'
> ```

## Test the end-to-end flow

To test the XAA Token Vault flow, your application must:

1. [Obtain an Auth0 refresh token](#step-1-obtain-an-auth0-refresh-token) by completing an authorization code flow with your Requesting App connection (Okta Workforce, OIDC, or SAML).
2. [Exchange the refresh token](#step-2-exchange-the-refresh-token-with-token-vault) for a Resource App access token with the OIDC connection using the Token Vault grant type or the Resource App connection.

Use the application you configured in [Configure your Token Vault application](#configure-your-token-vault-application) or an existing application with the Token Vault grant enabled.

### Step 1: Obtain an Auth0 refresh token

Your application uses the [authorization code flow](/docs/docs/get-started/authentication-and-authorization-flow/authorization-code-flow) with your Requesting App connection to authenticate the user and obtain an Auth0 refresh token.

#### Initiate the authorization request

Send the following `GET` request to the Auth0 `/authorize` endpoint, substituting your own values:

```bash theme={null}
GET https://{yourRequestingAppDomain}/authorize?
  response_type=code&
  client_id={yourApplicationClientId}&
  redirect_uri={yourCallbackUrl}&
  scope=offline_access&
  connection={yourRequestingAppConnectionName}
```

| Parameter | Description |
| - | - |
| `response_type` | Set to `code` to use the authorization code flow. |
| `client_id` | The **Client ID** of the application you configured in [Configure your Token Vault application](#configure-your-token-vault-application). |
| `redirect_uri` | The callback URL of your application. Must match an **Allowed Callback URL** configured in the application settings. |
| `scope` | Set to `offline_access` to request a refresh token. |
| `connection` | The name of your Requesting App connection, such as the Okta Workforce connection you configured in [Okta as OIDC IdP](/docs/docs/ai-agents-mcp/cross-app-access/requesting-app/idp/okta-as-oidc-idp). |

Your test user will be redirected to the enterprise IdP to authenticate. After a successful login, Auth0 redirects back to your `redirect_uri` with an authorization `code` in the query string.

#### Exchange the authorization code for a refresh token

Send a `POST` request to the Auth0 `/oauth/token` endpoint to exchange the authorization code for tokens:

```bash theme={null}
curl -X POST 'https://{yourRequestingAppDomain}/oauth/token' \
  --header 'Content-Type: application/json' \
  --data '{
    "grant_type": "authorization_code",
    "code": "{authorizationCode}",
    "client_id": "{yourApplicationClientId}",
    "client_secret": "{yourApplicationClientSecret}",
    "redirect_uri": "{yourCallbackUrl}"
  }'
```

| Parameter | Description |
| - | - |
| `grant_type` | Set to `authorization_code`. |
| `code` | The authorization code returned by Auth0 after the user authenticated. |
| `client_id` | The **Client ID** of the application. |
| `client_secret` | The **Client Secret** of the application. |
| `redirect_uri` | The same callback URL used in the authorization request. |

A successful response includes a `refresh_token`:

```json theme={null}
{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5...",
  "refresh_token": "v1.MjzFJHdw...",
  "id_token": "eyJhbGciOiJSUzI1NiIsInR5...",
  "token_type": "Bearer",
  "expires_in": 86400
}
```

### Step 2: Exchange the refresh token with Token Vault

Use the refresh token to call the Token Vault grant type endpoint and retrieve a Resource App access token.

```bash theme={null}
curl -X POST 'https://{yourRequestingAppDomain}/oauth/token' \
  --header 'Content-Type: application/json' \
  --data '{
    "client_id": "{yourApplicationClientId}",
    "client_secret": "{yourApplicationClientSecret}",
    "subject_token": "{refreshToken}",
    "grant_type": "urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token",
    "subject_token_type": "urn:ietf:params:oauth:token-type:refresh_token",
    "requested_token_type": "http://auth0.com/oauth/token-type/federated-connection-access-token",
    "connection": "{yourOidcConnectionName}" // or your Resource App connection name
  }'
```

| Parameter | Description |
| - | - |
| `client_id` | The **Client ID** of the application. |
| `client_secret` | The **Client Secret** of the application. |
| `subject_token` | The Auth0 refresh token obtained in [Step 1](#step-1-obtain-an-auth0-refresh-token). |
| `grant_type` | The Token Vault grant type: `urn:auth0:params:oauth:grant-type:token-exchange:federated-connection-access-token`. |
| `subject_token_type` | Set to `urn:ietf:params:oauth:token-type:refresh_token` to indicate that a refresh token is being exchanged. |
| `requested_token_type` | Set to `http://auth0.com/oauth/token-type/federated-connection-access-token` to request a Resource App access token. |
| `connection` | The name of the OIDC connection you configured in [Environment Setup](/docs/docs/ai-agents-mcp/cross-app-access/requesting-app/set-up-xaa-test-environment) with **Cross App Access for Token Vault** enabled or the Resource App connection. |

Token Vault uses the XAA flow to obtain an access token to the Resource App by looking for a stored refresh token from a valid Requesting App IdP, asking that IdP for an `ID-JAG` token on your behalf, and then presenting it to the Resource App in exchange for an access token, before returning the access token to your app.

A successful response returns a Resource App access token:

```json theme={null}
{
  "access_token": "eyJhbGciOiJSUzI1NiIsInR5...",
  "token_type": "Bearer",
  "expires_in": 86400
}
```

Your application can now use this access token to call the Resource App's API on the user's behalf.

## Handle multiple Requesting App IdPs

An Auth0 tenant might have many connections configured to IdPs that support XAA as a Requesting App,
and which have XAA enabled (e.g. their `cross_app_access_requesting_app.active` property is set to
`true`).

When an application makes a token exchange request, Token Vault can only request an `ID-JAG` from an IdP that the user has already authenticated with. There must be exactly one valid user identity linked to the current
user's profile, where XAA is enabled on the connection authenticating the user, otherwise Token Vault will not know which IdP to request an `ID-JAG` from. If there are multiple valid identities, the request will fail with the following error:

```json theme={null}
{
    "error": "invalid_request",
    "error_description": "Multiple enterprise connections with XAA support enabled"
}
```

If the current user profile has more than 10 linked identities on connection types that support XAA
(i.e. Okta, OIDC, and SAML connection types) *even if those connections do not have XAA enabled* Token
Vault will fail with the error:

```json theme={null}
{
    "error": "invalid_request",
    "error_description": "User can have a maximum of 10 linked accounts to use XAA"
}
```

This limits the number of connections that Token Vault must check in order to locate a valid XAA
connection.

## Use Auth0 Organizations with XAA

Token Vault will also filter the available Requesting App connections by those that are enabled for
the current user's organization. An Auth0 solution that uses Organizations can limit access to each
IdP by Organization in order to clarify which Requesting App connection should be used for each
user session.

Each `subject_token` that is used in a Token Vault exchange contains information about the
organization that the user logged into. This organization context will be used to find the correct
XAA Requesting App connection. However, if multiple valid connections are found, the request will
still fail.

## Diagnosing issues

When a Token Vault exchange fails, the response to your application contains a short, fixed `error_description` that does not include details from the upstream IdP or Resource App authorization server. To find the cause, check your [tenant logs](/docs/docs/deploy-monitor/logs).

### Token exchange failures

A failed exchange creates a [`feta`](/docs/docs/tenant-logs/auth-token-exchange-success/feta) (Failed token exchange at Token Vault) log entry. The `details.failure_reason` field identifies what went wrong. When the IdP or Resource App authorization server returns an OAuth error, the entry also includes the upstream `error`, `error_description`, and HTTP status.

| `failure_reason` | Meaning |
| - | - |
| `tokenset_not_found` | Auth0 has no stored refresh token for this user and Requesting App connection. |
| `tokenset_failed_to_refresh` | The IdP rejected the stored refresh token as no longer valid. |
| `login_required` | The IdP requires the user to log in again. |
| `connection_misconfigured` | The Requesting App or Resource App connection is missing required configuration. |
| `upstream_unavailable` | The IdP or Resource App authorization server returned a server error, was unreachable, or timed out. |
| `id_token_missing` | The IdP did not return an ID token when Auth0 refreshed the user's token. |
| `id_jag_client_rejected` | The IdP could not authenticate the Requesting App connection's client, or does not allow it to request an ID-JAG. |
| `id_jag_access_denied` | The IdP denied access to the Resource App for this user or client. |
| `id_jag_request_rejected` | The IdP rejected the ID-JAG request, for example because of an unrecognized audience or invalid scopes. |
| `resource_client_rejected` | The Resource App authorization server could not authenticate the Resource App connection's client, or does not allow it to use the ID-JAG grant. |
| `resource_access_denied` | The Resource App authorization server denied access. |
| `id_jag_exchange_failed` | The Resource App authorization server rejected the ID-JAG as invalid, expired, or already used. |
| `unclassified` | Token Vault could not classify the failure. |

### Login failures

When a user logs in through a Requesting App connection, Auth0 stores the IdP refresh token that Token Vault later uses for the exchange. If Auth0 cannot store it, the login still succeeds but a `token_vault_xaa_refresh_token_acquisition_failed` log entry is created. The `details.failure_reason` field can have the following values:

* `no_refresh_token`: The IdP did not return a refresh token.
* `idp_failure`: The IdP rejected or could not complete the request. `details.error.message` describes the cause.
* `rate_limited`: Auth0 reached the Token Vault limit, so the refresh token was not stored.

Without a stored refresh token, later exchanges for that user fail with `tokenset_not_found`.
