RFC 8693 — OAuth 2.0 Token Exchange
Implemented (Phase 1 — JWT subject tokens)
Source: docs/oauth/RFC_8693.md
RFC 8693 — OAuth 2.0 Token Exchange ¶
Status: Standards Track
Published: 2020-01
L-tier / T-tier: L4 · T5
OneAuth coverage: Implemented (Phase 1 — JWT subject tokens)
See also:RFC_7523.md·LANDSCAPE.md
In one sentence ¶
Token Exchange lets a holder of one token swap it for another token —
typically used for delegation (“user A acts as user B”), impersonation
(“service S acts as user U”), and cross-domain federation (an upstream
JWT becomes a downstream access token).
What problem does it solve? ¶
| Without 8693 | With 8693 |
|---|---|
| Service-to-service auth with delegation requires custom protocols | One standardized exchange flow |
| GitHub Actions / GCP / AWS federation each defines its own JWT-to-cloud-token API | All speak token exchange under the hood |
| Tracking “who actually acted” through a delegation chain is ad-hoc | The act and may_act claims express the chain explicitly |
| Subject vs actor distinction is buried in vendor-specific claims | Spec-defined subject_token (whose authority) vs actor_token (who’s exercising it) |
8693 is the spec behind every “use this JWT to get a different token”
pattern. The famous public example: GitHub Actions has a workflow OIDC
token; AWS has IAM. The bridge (“AWS OIDC federation”) is RFC 8693
exchange.
Relatable example ¶
GitHub Actions deploying to AWS without static credentials:
- The CI job is issued a short-lived OIDC token by GitHub:
{iss: "https://token.actions.githubusercontent.com", sub: "repo:org/repo:ref:main", ...}. - The job calls AWS STS:
POST https://sts.amazonaws.com/?Action=AssumeRoleWithWebIdentity &WebIdentityToken=<github-oidc-jwt> &RoleArn=arn:aws:iam::123:role/github-deploy - AWS verifies the JWT against GitHub’s JWKS, applies its OIDC trust
policy, and returns AWS-format temporary credentials.
That’s a token exchange under the hood (AWS’s API predates 8693 and uses
its own request shape, but the operation is exactly what 8693 standardizes).
Newer cloud services and identity brokers ship the actual 8693 wire form.
Key concepts ¶
- Grant type:
urn:ietf:params:oauth:grant-type:token-exchange. - Two tokens in, one out (max):
subject_token(required) — whose authority the new token representsactor_token(optional) — who’s actually exercising the authority;
produces a delegation relationship
- Token type indicators are explicit (and use URIs, not magic strings).
subject_token_typeandactor_token_typeare one of
urn:ietf:params:oauth:token-type:{access_token,refresh_token,id_token,saml1,saml2,jwt}.
This lets the exchange take in any token shape it’s configured to
trust. - Output target negotiation:
audience,resource,scope, and
requested_token_typelet the caller ask for what they want — the AS
may grant less. - Delegation chain in the issued token uses the
actclaim
(RFC 8693 §4.1, also referenced by RFC 7519 conventions). If A
delegates to B who delegates to C, the issued token’s claims express
the chain so the RS can audit it.
Wire example ¶
POST /api/token HTTP/1.1
Host: as.example.com
Content-Type: application/x-www-form-urlencoded
Authorization: Basic <client-creds>
grant_type=urn:ietf:params:oauth:grant-type:token-exchange
&subject_token=eyJhbGciOiJSUzI1Ni...
&subject_token_type=urn:ietf:params:oauth:token-type:jwt
&audience=https://downstream-api.example.com
&scope=read+write
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: no-store
{
"access_token": "eyJhbGciOiJSUzI1NiIsImtpZ...",
"issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
"token_type": "Bearer",
"expires_in": 3600,
"scope": "read write"
}
The issued access token’s claims reflect the subject (and optionally actor,
chained via act) from the original.
Where it lands on the OAuth abstraction ¶
- L4 grant types. Token Exchange plugs into the
/tokenslot at T5
as another grant_type URI. - T5 (back-channel exchange). Pure server-to-server — no user
involvement; subject_token must already exist. - This is the spec that makes federated identity work across domains
without static shared credentials.
OAuth 2.0 status ¶
Published 2020. Part of the OAuth 2.0 family. Used today as the basis for
nearly every modern OIDC federation pattern — even when vendors use their
own wire formats, the semantics are 8693.
OAuth 2.1 status ¶
Not changed by 2.1. Token Exchange remains a peer grant_type alongside
auth-code and client_credentials.
OneAuth status ¶
| 8693 surface | Status | Where (grep-verified) | Notes |
|---|---|---|---|
grant_type=...:token-exchange dispatch |
Implemented | apiauth/token_endpoint.go case TokenExchangeGrantType → TokenEndpointHandler.dispatchTokenExchange; handler at apiauth/token_exchange_granter.go tokenExchanger.TokenExchange |
— |
subject_token parsing (Phase 1: JWT only) |
Implemented | apiauth/token_endpoint.go reads subject_token; TestTokenExchangeGrant_HappyPath in token_exchange_grant_test.go |
RFC 8693 §2.1 |
subject_token_type=...:jwt / ...:id_token |
Implemented | apiauth/token_exchange_granter.go accepts both; token_exchange_grant_test.go, id_jag_test.go exercise |
An id_token is validated as a signed JWT (MCP EMA presents one) |
actor_token (delegation) |
Not implemented (Phase 1 scope) | — | Future Phase 2; act claim shape needed. ID-JAG redemption leaves a // TODO(ext-auth#13) for the actor claim |
audience / resource request |
Partial | Advisory for access_token output; bound for id-jag output (audience→ID-JAG aud, resource→resource claim) |
Access-token audience-targeting still pending |
requested_token_type |
Implemented | access_token (default) and ...:id-jag (apiauth/token_exchange_granter.go) |
id-jag output is opt-in (see below) |
issued_token_type in response |
Implemented | Returned per RFC 8693 §2.2.1 | id-jag output returns token_type: N_A |
| Subject-token JWT signature validation | Implemented | ValidateAssertion in apiauth/jwt_bearer_grant.go, against the trusted issuer’s key |
Since 0.1.45 the subject token must carry exp and match a configured audience (TrustedAssertionIssuer.Audiences, else the AS audience or issuer URL). With none configured every exchange is refused |
may_act claim handling |
Not implemented | — | Future Phase 2. CustomClaimsFunc can’t set act or may_act on access tokens (0.1.45) |
Phase 1 covers the most common production case (JWT-bearer-style subject
token exchange). Phase 2 deepens delegation primitives — file as a follow-up
gap if a real consumer asks.
ID-JAG issuance (MCP Enterprise-Managed Authorization / SEP-990) ¶
requested_token_type=urn:ietf:params:oauth:token-type:id-jag mints an
Identity Assertion Authorization Grant instead of an access token — the
intermediate credential in the MCP EMA two-stage chain
(id_token → id-jag → MCP access token). Per
draft-ietf-oauth-identity-assertion-authz-grant-04:
- The ID-JAG is a signed JWT with header
typ: oauth-id-jag+jwtand claims
iss,sub,aud(the resource app’s AS, from the requestaudience),
client_id,jti,iat,exp, plusscope/resourcewhen supplied. - The response reports
issued_token_type= the id-jag URN and
token_type: N_A(RFC 8693 §2.2.1 — an ID-JAG is redeemed, not presented
as a bearer token). - An ID-JAG is not an access token. Since 0.1.45 the validator refuses one presented to a resource server, by its
typheader (checkAccessTokenKind). - Issuance is off by default. Wire
apiauth.NewJWTIDJAGIssuer(signed
with the IdP key) intoTokenExchangerConfig.IDJAGIssueror
OneAuthConfig.IDJAGIssuerto opt in — minting a cross-domain
authorization grant is a sensitive capability gated per #344.
Redemption is the sibling RFC 7523 jwt-bearer grant. See
apiauth/id_jag.go and the two-leg e2e in
client/enterprise_managed_e2e_test.go.
A confidential requesting client is authenticated on the exchange when its
client_id names a registered confidential client (issue 356,
apiauth/confidential_client_auth.go); public / unregistered clients keep the
assertion-only path. Since 0.1.41 an AppStore error other than not-found is a
500, where it used to treat the client as public.
When NOT to use it ¶
- Same-domain machine-to-machine auth — use
client_credentials. No
delegation needed; no second token to exchange. - Auth code + refresh flow — these are the right answer for browser
and mobile clients. Token Exchange is for credential bridging, not
for getting an initial token.
Related RFCs ¶
- RFC 7523 — JWT Bearer; sibling grant for “I have a JWT, give me a token” (simpler, no actor concept)
- RFC 6749 — the framework 8693 extends
- RFC 7519 — JWT subject_tokens live here
- RFC 9396 — RAR; token exchange can ask for and receive narrowed
authorization_details - OAuth 2.1 draft — unchanged
- RFC 9068 — the issued access token follows this profile