Token exchange
ProAuth implements OAuth 2.0 Token Exchange (RFC 8693). A receiving API can exchange a user's access token for a restricted token for another API. The receiving API authenticates as its own client application.
For example, a BFF calls Procurement with a token whose audience is Procurement. Procurement validates that request, then exchanges its token for a Fulfilment token. With DPoP, the incoming token is bound to the BFF's key and the new token is bound to Procurement's key. The BFF never shares its private key with Procurement.
Choose an exchange mode
Set tokenExchangeMode on the exchanging client's Authentication and token binding configuration, through the AdminApp or v2 Management API (ClientAppAuthenticationConfiguration).
| Mode | Behavior |
|---|---|
Legacy | Default for existing configurations. Preserves supported bearer user exchanges and service-principal federation. Sender-constrained subject tokens remain rejected. |
Disabled | Rejects all token exchanges for this client. |
Policy | Requires exactly one enabled, matching exchange policy. There is no fallback to legacy behavior. |
The JSON enum values are legacy, disabled, and policy; binding values are bearer, dpop, and mutualTls.
Use Policy for new API delegation. Use asymmetric client authentication (private_key_jwt or an mTLS method) where possible. DPoP proves possession of a token-binding key; it does not replace client authentication.
Register an explicit policy
Under the receiving client's Permissions → Token exchange policies, add a policy. Policies are also available through api/management/v2/ClientAppTokenExchangePolicy and the CLI's tokenExchangePolicies owned collection. Reading policies through the API requires ClientApp.Read within the receiving client's scope.
Each policy specifies:
| Field | Meaning |
|---|---|
name, enabled | Unique name within the receiving client; new policies are disabled by default. |
allowRefreshTokens | Default false. Explicitly allow continuing delegation through a refresh token when offline_access is requested. |
tenantId | Tenant in which the exchange is permitted. |
sourceClientAppId | Original client to which the incoming user token was issued, such as the BFF. |
inputAudience | Exact audience identifying the receiving API. |
requiredInputScopes | Space-separated scopes that must all be present in the incoming token. |
inputBinding | Bearer, Dpop, or MutualTls. |
outputAudience | One exact downstream API audience. Wildcards are unsupported. |
allowedOutputScopes | Space-separated allowlist of downstream scopes. These may differ from incoming scope names. |
outputBinding | Required binding of the new token: Bearer, Dpop, or MutualTls. |
maximumLifetimeSeconds | 1–3600 seconds; default 300. Initial access-token expiry is also bounded by the incoming token and normal token lifetime. |
The receiving and original clients must be enabled and assigned to the same tenant and subscription. Add the original client to the receiving client's allowedTokenExchangeClientApps relationship. Existing resource and scope filters still apply. Requests with no matching policy or multiple matching policies are rejected; permissions from different policies are never combined.
Example v2 policy creation body, using your registered IDs:
{
"clientAppId": "22222222-2222-4222-8222-222222222222",
"name": "Procurement to Fulfilment",
"enabled": true,
"allowRefreshTokens": false,
"tenantId": "33333333-3333-4333-8333-333333333333",
"sourceClientAppId": "11111111-1111-4111-8111-111111111111",
"inputAudience": "https://api.example.com/procurement",
"requiredInputScopes": "orders.read",
"inputBinding": "dpop",
"outputAudience": "https://api.example.com/fulfilment",
"allowedOutputScopes": "shipments.read",
"outputBinding": "dpop",
"maximumLifetimeSeconds": 300
}Updates and deletes use the current resource's ETag in If-Match, as with other v2 resources. The parent client owns policies; deleting it deletes its policies.
Supported binding combinations
| Incoming token | Allowed downstream binding, with an explicit policy |
|---|---|
| Bearer | Bearer, DPoP, mTLS |
| DPoP | DPoP, mTLS |
| mTLS | mTLS, DPoP |
A sender-constrained token can never become a bearer token. For DPoP output, send a fresh proof signed by the receiving API's key for the token endpoint. For mTLS output, present the receiving API's certificate through TLS or the configured trusted certificate-forwarding infrastructure. Supplying both output binding mechanisms is rejected by policy-controlled exchange.
dpopBoundAccessTokens, requireDpopNonce, and requireCertificateBoundAccessTokens retain their existing client-wide meaning. A policy cannot weaken them. Use outputBinding to require DPoP specifically for exchanges without changing the client's other grants.
The tenant option TokenExchangeRequiredOutputBinding sets an additional minimum for all exchanges, including legacy mode:
None(default): rely on client settings and explicit policies.Dpop: require a validated DPoP proof.MutualTls: require certificate binding.SenderConstrained: require either binding.
FAPI clients additionally require tenant option AllowFapi2TokenExchange=true and client mode Policy. Existing FAPI asymmetric-authentication, algorithm and sender-constraint requirements remain enforced. This enables an OAuth extension alongside the configured FAPI profile; it does not assert FAPI certification of the extension.
Receiving API responsibilities
A policy authorizes ProAuth to trust the receiving API's validation of the incoming request. Before exchange, the API must validate the token's issuer, audience, lifetime and authorization, and the caller's DPoP proof or TLS certificate when bound. Validate the DPoP access-token hash, request method/URI, key thumbprint and replay protection. Never forward the incoming proof as the token endpoint proof.
With ProAuth.Oidc.ResourceServer.AspNetCore, enable BearerAndSenderConstrained to accept both supported legacy bearer requests and bound requests, or select a required binding policy. BearerOnly rejects sender-constrained tokens. After successful authentication and endpoint authorization, obtain the original token using:
using ProAuth.Oidc.ResourceServer.AspNetCore.Authentication;
var subjectToken = httpContext.GetValidatedAccessToken();
var result = await oidcClient.ExchangeTokenAsync(
subjectToken,
"urn:ietf:params:oauth:token-type:access_token",
requestedTokenType: "urn:ietf:params:oauth:token-type:access_token",
scopes: ["shipments.read"],
audience: "https://api.example.com/fulfilment",
cancellationToken: cancellationToken);Configure this IOidcClient with the receiving API's credentials and its own DPoP key or mTLS certificate. The helper throws if successful ProAuth authentication has not supplied a token for the selected scheme. Do not log or persist the incoming token.
When calling the downstream API, use the returned token type and the same API key or certificate that bound the exchanged token. For DPoP, configure the client package's DpopProofHandler on that outbound HTTP client so each downstream request receives a fresh proof containing the access-token hash. Do not send a DPoP token as a plain bearer token.
This model protects against unauthorized exchange clients and permission escalation. It cannot prove that a compromised, explicitly trusted receiving API actually validated the original caller. Restrict policy administration, protect API credentials and keys, and authorize only the necessary source, tenant, audience, scopes and lifetime.
Request and response contract
Send grant_type=urn:ietf:params:oauth:grant-type:token-exchange, the incoming subject_token, subject_token_type=urn:ietf:params:oauth:token-type:access_token, explicit scope, and one downstream audience or resource. Use audience=fulfilment for a logical service name. Every resource must be an absolute URI without a fragment, such as urn:example:fulfilment or https://api.example.com/fulfilment; query components are allowed. Relative paths, plain names and URI fragments are rejected with invalid_target in both Legacy and Policy modes. Authenticate the receiving client. requested_token_type is optional and is one token-type identifier, never a space-separated list.
Policy mode currently accepts local, same-issuer, same-tenant user access tokens, including reference and encrypted tokens resolved by ProAuth. It does not accept ID tokens, external tokens, machine subject tokens, caller-supplied actor_token, or existing actor chains. Refresh-token issuance and offline_access require explicit allowRefreshTokens=true on the matching policy. Existing external service-principal federation remains available in Legacy mode with registered issuer/subject mappings and the original-client allowlist.
Successful responses contain access_token, issued_token_type, token_type, expires_in, and the granted scope. In Policy mode, the downstream access token contains issuer-generated act with the authenticated API's client ID as sub and ProAuth's issuer as iss. Its user subject follows the downstream client's subject-identifier policy. Authentication context comes from the stored source context; the exchange does not establish a fresh login or stronger authentication.
ProAuth checks the subject token's active state at exchange time. Revoking it prevents subsequent exchanges, but does not establish a cascading revocation relationship with already issued downstream tokens. Those tokens remain subject to their own expiry and the existing session/security-context validation. A resource server validating JWTs locally does not discover revocation immediately; use the existing introspection controls when live status is required.
Legacy bearer exchanges requesting offline_access retain their supported refresh behavior. In either mode, if explicitly requesting a refresh token as the issued token, RFC 8693 places it in access_token, sets issued_token_type to the refresh-token type, and uses token_type=N_A.
Invalid, expired, revoked or otherwise unacceptable subject tokens return invalid_request, as specified by RFC 8693. Unavailable or invalid exchange targets return invalid_target. Supplied actor_token and actor_token_type parameters are unsupported and rejected in both modes; Policy mode establishes the emitted actor identity from the authenticated exchanging client; Legacy mode retains its existing claim behavior.
Optional refresh tokens and long-running sessions
Refresh tokens are explicitly supported by RFC 8693 section 2.2.1. Issuance is optional and governed by deployment policy. The default prohibition in Policy mode is a ProAuth security default, not a restriction imposed by OAuth.
For a long-running SignalR connection or another delegated background session:
- Enable Allow refresh tokens on the receiving client's exchange policy. This is also the v2/CLI
allowRefreshTokensfield. - Include
offline_accessin the receiving client's allowed scopes, alongside the downstream permissions. Keep the policy'sallowedOutputScopeslist limited to API permissions; the checkbox separately authorizesoffline_access. - Exchange a currently valid source access token with
scope=shipments.read offline_access. Request an access token, or omitrequested_token_type, to receive bothaccess_tokenandrefresh_token. - Use the normal
refresh_tokengrant with the same receiving client credentials and, for bound grants, the same DPoP key or mTLS certificate. A fresh source access token is not required for each renewal.
Initial access-token expiry is capped by the source token. An explicitly authorized refresh grant can outlive that source access token. The existing tenant/claim-configured refresh lifetime, rotation, reuse, session and authentication-security controls apply; this setting does not make the session immortal. Subsequent access tokens remain capped by the policy's maximum access-token lifetime, normal access-token lifetime and the current refresh token's remaining lifetime. Keep refresh tokens and binding keys in protected server-side storage.
Every renewal rechecks the current policy, source-client permission and tenant membership, client requirements and tenant binding floor. Disabling the policy or its refresh permission, removing the original-client allowlist entry, changing its audience/binding, or removing granted scopes blocks further renewal. Changing back to Legacy mode does not bypass these checks. Newly added policy permissions do not enlarge an existing grant. The API actor and original authentication provenance remain intact, and refresh does not create a new ID token for this delegation.
DPoP and mTLS refresh grants retain the API's original binding; changing keys/certificates requires a new exchange. Bearer policies may explicitly allow refresh tokens too. The original source token's expiry alone does not invalidate an issued refresh grant; source-token revocation does not automatically cascade to it. Session logout, grant revocation and authentication-security invalidation still apply through the existing controls.
Introspection token types
For active access tokens, JSON and signed introspection responses report token_type=DPoP for DPoP binding and token_type=Bearer for ordinary bearer or mTLS-bound tokens. The cnf member retains the corresponding key/certificate thumbprint. These values describe how the access token is presented; access_token and refresh_token are request hints, not access-token presentation types. Refresh-token introspection omits the optional token_type field.
Rollout
Apply the normal database migrations for your SQL Server or PostgreSQL deployment and deploy matching server, CLI, AdminApp resources and client packages. Existing configurations default to Legacy; ordinary non-exchange grants are unchanged. Create disabled policies, configure the receiving API to validate incoming proofs, then enable policies and switch that client to Policy. Tighten tenant requirements after the affected clients can supply the required bindings.
Update integrations that previously sent a space-separated requested_token_type list: that nonstandard syntax is now rejected. Request an access token with one identifier (or omit the parameter); request offline_access when a separate refresh token is needed, and enable allowRefreshTokens when using Policy mode. Clients explicitly requesting a refresh token must read it from the RFC 8693 access_token response field and inspect issued_token_type.
Customers using a logical name in the token-exchange resource parameter must move that value to audience, or register and send an absolute resource URI. Consumers of introspection must use Bearer/DPoP rather than interpreting access_token as a presentation type. These protocol corrections apply in Legacy mode as well.
Legacy integrations must remove previously ignored actor-token parameters. Update error handling that expected invalid_token for a rejected exchange subject or invalid_request for a denied exchange target. These corrections do not change errors for other grant types.