One hop of token exchange
- 1Orders service → Authorization serverUser's token, for paymentssubject_token, audience, scope
- 2Authorization server → Authorization serverNo scope beyond the subject's
- 3Authorization server → Orders serviceNew token, payments onlysub is the user, act is orders
- 4Orders service → Payments serviceCall with the new token
The orders service sends the user's token to the authorization server as the subject token, asking for the payments audience and the payments:charge scope. The server refuses any scope the subject token does not carry. It returns a new token for payments only, naming the user as subject and the orders service as actor. The orders service calls the payments service with that token.
A user calls your API gateway. The gateway calls an orders service. The orders service calls a payments service. Each hop needs to act on behalf of the same user, but none of them should hold a token that works everywhere. OAuth 2.0 token exchange, standardised in RFC 8693, gives each hop a token of its own: same user, narrower audience, fewer scopes, and a record of who is acting.
How OAuth token exchange works
Token exchange is a grant type at the authorization server’s token endpoint. The client sends the token it holds, called the subject token, and asks for a new one.
POST /token HTTP/1.1
Host: auth.example.com
Content-Type: application/x-www-form-urlencoded
grant_type=urn:ietf:params:oauth:grant-type:token-exchange
&subject_token=eyJhbGciOi...
&subject_token_type=urn:ietf:params:oauth:token-type:access_token
&audience=https://payments.example.com
&scope=payments:charge
The main request parameters:
| Parameter | Meaning |
|---|---|
subject_token, subject_token_type |
The token representing the party the new token is about |
actor_token, actor_token_type |
Optional: the token of the party acting, for delegation |
audience / resource |
Where the new token will be used |
scope |
The scopes requested, usually a subset of the subject’s |
requested_token_type |
The format wanted, for example an access token or a JWT |
The response carries access_token, issued_token_type, token_type, and
usually expires_in. The client authenticates itself on the request as it
would for any token request, for example with a JWT client
assertion.
Delegation and the act claim
RFC 8693 distinguishes two semantics.
- Impersonation. The new token represents the subject alone. Downstream services cannot tell an intermediary was involved.
- Delegation. The new token names the subject and the actor. In a JWT
this is the
actclaim:
{
"sub": "user:ada",
"aud": "https://payments.example.com",
"scope": "payments:charge",
"act": { "sub": "spiffe://example.org/orders/api" }
}
act can nest, so a chain of services leaves a visible trail. RFC 8693 also
defines may_act, which a subject token can carry to state who is allowed
to act on its behalf.
Where token exchange fits
- Microservice call chains, where each service needs an on-behalf-of token for the next. See delegated authorization.
- Workload identity federation, where a workload trades a token from one issuer, such as a Kubernetes or SPIFFE identity, for an access token from another.
- Down-scoping, where a broad token is traded for a narrow one before it leaves a trusted boundary.
- Format translation, where one system issues JWTs and another expects a different token type.
Some token formats, such as Biscuit, can also be narrowed locally without a round trip. Exchange remains the way to change audience or obtain a new signature from the issuer.
Exchange vs forwarding
| Forward the user’s token | Exchange per hop | |
|---|---|---|
| Audience | Whatever the original token allowed | Bound to the next service |
| Scope | Everything the user granted | Only what this hop needs |
| Who acted | Invisible | Named in act with delegation |
| Blast radius of a leak | Every service accepting the token | One service, narrow scope |
| Cost | None | One token request per hop, cacheable |
Pitfalls
- Scope widening. The server must refuse requests for scopes the subject token does not carry.
- Missing audience. A delegated token with no audience can be replayed at
every service. Require and enforce
audience. - Unauthenticated exchange. Only known clients should be allowed to exchange tokens; authenticate the client on every request.
- Ignoring the actor. If services authorize on
subalone, delegation is invisible and audit trails lose the intermediary. - Unbounded chains. Cap delegation depth.
- Lifetime drift. The issued token should not outlive the subject token.
How QuorumAuth handles token exchange
QuorumAuth offers a delegation operation modelled on RFC 8693’s on-behalf-of
semantics, served through its own SDK API rather than as the standard
grant_type at a form-encoded token endpoint. In its tested behaviour:
- An authenticated actor can obtain a delegated token for an audience and a scope. A request with no access token is unauthenticated, an empty audience is invalid, and a request for scope the subject does not hold is denied.
- The delegated token is bound to the audience it was asked for and keeps the token format the caller presented.
- Verification reports who acts as well as for whom; a token nobody delegated names no actor and no delegation hop.
- Biscuit tokens can instead be narrowed locally. A narrowed token keeps only the scope it was given, cannot regain what it gave up, carries its delegation depth, and names the service it is addressed to.
- A workload can exchange its SPIFFE identity over mutual TLS (mTLS) for a short-lived access token that never outlives the identity that obtained it.
For AI agents, this means a delegated token narrowed to the agent’s task instead of the user’s full session.
Frequently asked questions
What is the difference between delegation and impersonation?
In impersonation the new token represents only the subject. In delegation it names both the subject and the actor working for them, usually in an act claim.
Why not just forward the user's token downstream?
A forwarded token is valid wherever its audience allows, often with all the user's scopes. Exchange gives each hop a token bound to one audience with only the scopes it needs.
Which grant type does token exchange use?
urn:ietf:params:oauth:grant-type:token-exchange, sent to the authorization server's token endpoint.
Can token exchange widen permissions?
The specification lets the authorization server decide. A safe server never issues more than the subject token already allowed.