Skip to main content
Integrate Token Vault into your applications without migrating your user identity store to Auth0. Primary authentication stays with your user identity provider (IdP), whether custom, third-party, local database, or a B2C/B2B solution, while Auth0 securely stores, rotates, and dispenses third-party OAuth access tokens for autonomous AI workflows. Using Custom Token Exchange (RFC 8693), you exchange a token issued by your user IdP for Auth0 tokens, provisioning a lightweight just-in-time (JIT) shadow profile. You then link third-party provider accounts to that profile using the Connected Accounts flow, and your backend or agents retrieve short-lived downstream tokens on demand, without ever handling long-lived credentials directly.
Using Custom Token Exchange alongside Token Vault provides an interim solution for enabling AI agents without migrating user stores. Auth0 will soon support a native solution powered by ID-JAG (Cross App Access) to standardize cross-app authorization without requiring custom token exchange engineering.

Architecture overview

Prerequisites

  • Auth0 tenant: An active tenant, with Organizations enabled if you are using multi-tenant or B2B structures.
  • User IdP capabilities: A primary identity provider capable of issuing signed OIDC ID tokens or JWT assertions, backed by a public JWKS endpoint or static key for signature verification.
  • Third-party developer credentials: Active client credentials (Client ID and Client Secret) for each downstream provider your AI agents need to access, such as GitHub, Google Workspace, or Salesforce.
  • Tenant administrator access: Permissions within your Auth0 tenant to create client applications, configure OAuth connections, and deploy Custom Token Exchange Actions.

Step 1: Setup and application registration

Register and configure your application

Navigate to Applications > Applications and create your application. Configure it as a first-party, confidential, OIDC-conformant application with Custom Token Exchange enabled:
  • Disable Allow Refresh Token Rotation for the application. Repeated token retrievals rely on reusing the same subject token, so rotation would break downstream access.
  • Under Advanced Settings > Grant Types, make sure Refresh Token and Token Vault are selected.
  • Under APIs > Auth0 My Account API, grant the application access to the My Account API (obtained through a multi-resource refresh token) with these scopes:
    • read:me:connected_accounts
    • create:me:connected_accounts
    • delete:me:connected_accounts
Then, under Applications > APIs, select Allow Skipping User Consent on the target API.

Register downstream OAuth connections

For each third-party provider your AI agents need to access:
  1. Navigate to Authentication > Social or Authentication > Enterprise.
  2. Add the connection using credentials from the provider’s developer portal.
  3. Under Purpose, enable Connected Accounts for Token Vault on the connection.
  4. Under Permissions, select Offline Access, allowing your client application to obtain a refresh token from the external provider.
  5. Under the connection’s Applications tab, enable your registered application.
To learn more, read Connected Accounts for Token Vault.

Step 2: Configure the Custom Token Exchange Action

Create a new Action under Actions > Library > Custom using the Custom Token Exchange trigger (onExecuteCustomTokenExchange). This Action validates the token issued by your User IdP, creates a shadow user profile in Auth0, and, optionally, scopes the access token to an Auth0 Organization.
Then create a Custom Token Exchange Profile using the Management API, linking a custom subject_token_type to this Action. The URN must not use a reserved namespace (urn:ietf, urn:auth0, urn:okta, and so on):

Step 3: Exchange your IdP token for an Auth0 My Account API access token

Send a token exchange request (RFC 8693) from your application backend to obtain an Auth0 My Account API access token scoped to the user’s Organization.
The response contains a My Account API access token and a refresh token. Use the Connected Accounts flow to authorize third-party OAuth providers, such as GitHub, Google Workspace, or Salesforce, without setting Auth0 as the user’s primary login.

Step 5: Retrieve third-party tokens for AI agents

Agents retrieve unexpired downstream access tokens directly from Token Vault using the refresh token exchange.

Step 6: Execute AI agent tool calls

Pass the retrieved provider token into third-party SDKs to perform API actions on the user’s behalf.