Docs
Live demo

Token exchange

Exchange a workload's OIDC JWT for an application token as a service account.

On this page

On a service account card in People.

How it works#

Send tokenWorkload sends its OIDC JWT to Dex.
Hand offDex forwards it to the Principal connector.
VerifyPrincipal checks issuer, subject, signature, expiry, audience, rules.
IssueDex returns a token for the client.

Evaluated per exchange: deleting the rule, trust or membership blocks future exchanges (issued tokens expire normally).

On this screen#

Element Action
Trusted token
Issuer, subject, audience, Pasted keys. Remove deletes.
Add trusted token
Opens form below.
Field Value
Issuer
Exact iss claim.
Subject
Exact sub claim (no wildcards).
Audience
Required aud value.
Public keys (optional)
JWKS for unreachable issuers (private Kubernetes).

The exchange request#

bash
curl -s https://dex.example.com/token \
  -d grant_type=urn:ietf:params:oauth:grant-type:token-exchange \
  -d client_id=vault \
  -d connector_id=principal-$APPLICATION_ID \
  -d subject_token="$SUBJECT_TOKEN" \
  -d subject_token_type=urn:ietf:params:oauth:token-type:id_token \
  -d requested_token_type=urn:ietf:params:oauth:token-type:id_token \
  -d scope="openid groups"
Parameter Value
client_id
Dex client with Principal connector (confidential clients include secret).
connector_id
principal- + application ID.
subject_token_type
id_token, jwt or access_token (signed JWT).
Response
Dex token in access_token.

Issuer and subject examples (GitLab CI, GitHub Actions, Kubernetes).

States and statuses#

Dex returns access_denied. Audit log reasons:

Reason Check
No service account trusts the issuer and subject
Exact iss and sub.
Signature does not match
Pasted keys or issuer.
Token expired, not valid yet
Clock and lifetime.
Issued for another audience
Issuer and trust audience.
Not allowed to use this application
Rule and org membership.
Principal could not read the keys of the issuer
Paste JWKS.

Limits and permissions#

  • Requires security-settings permission and fresh MFA (or Allow security changes token).
  • Unique issuer and subject per org.
  • Public OIDC discovery only (cached up to 1 day if unreachable).
  • Removed keys stay valid ~1 h when active (up to 1 day if idle/down). Delete trust to revoke now.
  • Pasted JWKS never auto-update.

Let a program sign in with its own token, Protect a web application, Applications, Identities.

In the API#

GET /identities/{id}/token-exchange-trusts, POST /identities/{id}/token-exchange-trusts, DELETE /identities/{id}/token-exchange-trusts/{trust_id}.

↑ ↓ to moveEnter to openEsc to close