Token Exchange (RFC 8693)
Lernen Sie die OAuth2-Erweiterung Token Exchange kennen, mit der Services Tokens austauschen können, um Delegation und Impersonation über Service-Grenzen hinweg zu unterstützen.
Token Exchange (RFC 8693) ist eine kostenlose OAuth2 & OpenID Connect Deep Dive-Lektion auf CoddyKit. Dies ist Lektion 4 von 4. Du kannst die komplette Lektion unten kostenlos lesen – dann übst du sie direkt im Browser mit einem integrierten Code-Editor und einem KI-Tutor rund um die Uhr. Sie ist Teil des OAuth2 & OpenID Connect Deep Dive-Lernpfads, und dein Fortschritt wird über Web und CoddyKit-App synchronisiert. Der OAuth2 & OpenID Connect Deep Dive-Kurs umfasst insgesamt 4 Lektionen.
Teile dieser Lektion wurden noch nicht übersetzt und werden auf Englisch angezeigt.
What Problem Does It Solve?
In a microservices world, Service A receives a token from a user, then must call Service B on the user's behalf. Forwarding the original token everywhere is risky — it may have the wrong audience or too-broad scopes.
Token Exchange (RFC 8693) lets a service trade an incoming token for a new, narrower or differently-scoped token from the authorization server.
Delegation vs Impersonation
Two distinct patterns:
- Impersonation — the new token looks like it belongs purely to the user; downstream cannot tell a middle service was involved.
- Delegation — the new token records both the user and the acting service via an
actclaim, preserving the chain.
The Grant Type
Token Exchange defines a new grant type sent to the standard token endpoint:
urn:ietf:params:oauth:grant-type:token-exchange
It does not need a browser or user interaction — it is a direct back-channel call.
Key Parameters
The request uses several parameters:
subject_token+subject_token_type— the token to exchange.actor_token— optional, identifies the acting party.audience/resource— the target service.scope— requested scopes for the new token.
Token Type URIs
Token types are identified by URIs, for example:
urn:ietf:params:oauth:token-type:access_tokenurn:ietf:params:oauth:token-type:jwturn:ietf:params:oauth:token-type:id_token
An Exchange Request
Service A exchanges the user's access token for a token scoped to Service B:
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://serviceB.example.com
&scope=read:ordersThe Exchange Response
The response includes the new token plus an issued_token_type telling the caller what it received.
{
"access_token": "eyJ0eXAiOi...",
"issued_token_type": "urn:ietf:params:oauth:token-type:access_token",
"token_type": "Bearer",
"expires_in": 600,
"scope": "read:orders"
}The act Claim
In delegation mode, the issued JWT contains an act (actor) claim nesting the acting party inside the subject. This lets the resource server audit who acted on whose behalf.
{
"sub": "user-42",
"aud": "https://serviceB.example.com",
"act": { "sub": "service-A" }
}Downscoping
A powerful use is downscoping: a service holding a broad token exchanges it for one with fewer scopes before passing it downstream. This honors least privilege so a compromised downstream service cannot do more than it needs.
When to Use It
Reach for Token Exchange when:
- Crossing trust or audience boundaries between services.
- You need an auditable delegation chain.
- You want to narrow scopes for downstream calls.
Avoid blindly forwarding the original token across services.
Security Notes
The authorization server must authenticate the requesting client and verify it is permitted to exchange the subject token for the requested audience. Always set a correct aud so tokens cannot be replayed against other services.
Quick Check
Check your grasp of Token Exchange.
Recap
Token Exchange (RFC 8693) trades one token for another via grant type token-exchange.
- Supports impersonation and delegation (the
actclaim). - Lets services downscope and re-audience tokens for downstream calls.
- Requires the AS to authenticate the client and validate the target audience.
Lerne OAuth2 & OpenID Connect Deep Dive mit einem KI-Tutor — kostenlos
Schreibe und führe echten Code in deinem Browser aus, bekomme sofortige Hilfe von einem 24/7 KI-Tutor und setze dein Lernen im Web oder in der App fort.
- Kurse
- 12
- Lektionen
- 48
Häufig gestellte Fragen
Ist die Lektion „Token Exchange (RFC 8693)“ kostenlos?
Ja — der vollständige Text von „Token Exchange (RFC 8693)“ ist hier im Web kostenlos zu lesen. Um sie interaktiv zu üben (integrierter Code-Editor und 24/7 KI-Tutor) und den Rest des OAuth2 & OpenID Connect Deep Dive-Kurses freizuschalten, upgrade auf CoddyKit PRO. Der OAuth2 & OpenID Connect Deep Dive-Kurs umfasst insgesamt 4 Lektionen.
Was lerne ich in „Token Exchange (RFC 8693)“?
Lernen Sie die OAuth2-Erweiterung Token Exchange kennen, mit der Services Tokens austauschen können, um Delegation und Impersonation über Service-Grenzen hinweg zu unterstützen. Du übst OAuth2 & OpenID Connect Deep Dive mit praktischem Code, den du direkt im Browser ausführst, und ein 24/7 KI-Tutor beantwortet deine Fragen während du die Lektion bearbeitest.
Brauche ich Erfahrung, um OAuth2 & OpenID Connect Deep Dive zu starten?
Keine Vorkenntnisse erforderlich. OAuth2 & OpenID Connect Deep Dive auf CoddyKit ist für Anfänger bis fortgeschrittene Lernende strukturiert, sodass du hier starten oder von Anfang an beginnen und in deinem eigenen Tempo voranschreiten kannst. Dies ist Lektion 4 von 4.
Wie lange dauert die Lektion „Token Exchange (RFC 8693)“?
Die meisten CoddyKit-Lektionen dauern etwa 5–10 Minuten. Jede ist kompakt und interaktiv, sodass du stetig Fortschritte machst und genau dort weitermachst, wo du aufgehört hast – im Web und in der App.
Kann ich in dieser OAuth2 & OpenID Connect Deep Dive-Lektion Code schreiben und ausführen?
Ja. Jede OAuth2 & OpenID Connect Deep Dive-Lektion enthält einen integrierten Code-Editor, sodass du echten Code direkt in deinem Browser schreibst und ausführst und sofort KI-Feedback erhältst — ohne lokale Einrichtung erforderlich.
Alle Lektionen in diesem Kurs
- PKCE für Public Clients
- Refresh Tokens und Scopes
- Resource-Owner-Password-Credentials
- Token Exchange (RFC 8693)