Skip to main content

Documentation Index

Fetch the complete documentation index at: https://auth0-feat-docs-5498.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

To use Custom Token Exchange, make a POST request to the /oauth/token endpoint with the following parameters:
Remember that subject and actor tokens used with Custom Token Exchange can be any token format or type, as long as your Action code can interpret them. You must implement strong validation of the tokens you receive and accept. If you fail to do so, you open yourself up to different attack vectors, such as spoofing or replay attacks, resulting in bad actors being able to authenticate with someone else’s user ID or acting on their behalf in an unauthorized manner.Each subject_token_type maps to a Custom Token Exchange Profile and is associated with an Action that will be executed to control that transaction.
ParameterDescription
grant_typeFor Custom Token Exchange, use urn:ietf:params:oauth:grant-type:token-exchange.
subject_token_typeThe type of the subject token. For Custom Token Exchange, this can be any URI scoped under your own ownership, such as http://acme.com/legacy-token or urn:acme:legacy-token.

The following namespaces are reserved and cannot be used:
  • http://auth0.com
  • https://auth0.com
  • http://okta.com
  • https://okta.com
  • urn:ietf
  • urn:auth0
  • urn:okta
subject_tokenThe subject token, which your action should validate and use to identify the user.
client_idThe client ID of the application you are using for the Token Exchange. As for other grant types, you can also pass the client ID in the Authorization header using HTTP Basic Auth.
client_secretThe client secret of the application you are using for the Token Exchange. As for other grant types, you can also pass the client secret in the Authorization header using HTTP Basic Auth.

Other alternatives are also available as explained in Auth0 Authentication API reference docs.

Note Custom Token Exchange can be used by public Applications. Make sure to read Attack Protection in that case.
audienceThe API identifier defined in Auth0. The default tenant audience will be used when not present, as configured in Tenant Settings.
scope(Optional) The OAuth2 scope parameter.
organization(Optional) The organization identifier you want the request to be associated with. Alternatively, you can specify an organization name if Use Organization Names in Authentication API is allowed for your tenant. To learn more about how the request is processed, read about the api.authentication.setOrganization() API method.
actor_token(Optional) A token identifying the actor or the principal performing delegation on behalf of the subject user. Must be provided together with actor_token_type.
actor_token_type(Optional) The type of the actor token. Must be provided together with actor_token. For Auth0 ID tokens, use urn:ietf:params:oauth:token-type:id_token for automatic server-side validation. For other values, follow the same namespace restrictions as subject_token_type.
When an actor is set for the transaction, refresh tokens are not issued regardless of requested scopes. The offline_access scope is excluded from the response. This is by design: delegated tokens should not outlive the immediate exchange, ensuring that each subsequent access request goes through the CTE Action’s authorization logic to re-validate the delegation.Your CTE Action is responsible for securely validating the actor_token by applying the same rigor (e.g., cryptographic signature verification) as you would for the subject_token. When actor_token_type is urn:ietf:params:oauth:token-type:id_token, Auth0 performs this validation automatically.
Other extension parameters not listed above are included in the event.request.body in the corresponding Action.

Sample request

curl --location 'https://{yourDomain}/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=urn:ietf:params:oauth:grant-type:token-exchange' \
--data-urlencode 'audience=https://api.acme.com' \
--data-urlencode 'scopes=openid offline_access acme-scope1 acme-scope2' \
--data-urlencode 'subject_token_type=urn:acme:external-idp-migration' \
--data-urlencode 'subject_token=t8e7S2D9trQm73e .... iqBR3GjxDtbDVjpfQU' \
--data-urlencode 'client_id=<YOUR_CLIENT_ID>' \
--data-urlencode 'client_secret=<YOUR_CLIENT_SECRET>'
--data-urlencode 'organization=periscope-acme'

Sample request with actor token

When performing a delegated authorization exchange, include actor_token and actor_token_type:
curl --location 'https://{yourDomain}/oauth/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'grant_type=urn:ietf:params:oauth:grant-type:token-exchange' \
--data-urlencode 'audience=https://api.acme.com' \
--data-urlencode 'scopes=openid acme-scope1 acme-scope2' \
--data-urlencode 'subject_token_type=urn:acme:legacy-token' \
--data-urlencode 'subject_token=t8e7S2D9trQm73e .... iqBR3GjxDtbDVjpfQU' \
--data-urlencode 'actor_token=eyJhbGciOiJSUzI1NiI .... kXdF9tZ3c' \
--data-urlencode 'actor_token_type=urn:ietf:params:oauth:token-type:id_token' \
--data-urlencode 'client_id=<YOUR_CLIENT_ID>' \
--data-urlencode 'client_secret=<YOUR_CLIENT_SECRET>'