Use this when working with SAML assertions, ID, access or refresh tokens.
Tokens
Tokens in SSO and federation are signed data structures — SAML assertions, ID tokens, access and refresh tokens — that carry identity and authorization between identity provider, client and APIs.
1. Tokens carry authentication/authorization (JWT, opaque).
2. Always validate signature and claims.
3. Short lifetimes.
4. Protect in storage (no localStorage for sensitive).
5. Revoke on risk.
issuer signs token → client presents → API validates
Context & applicabilityCommon mistakes · platform/version boundaries
Operational reference
Fast context before you go deeper.
Verification & Troubleshooting
Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.
Use the operational verification above to establish the expected state.
Capture the concrete output, symptom, packet, log or counter before changing anything.
Step 1 Checks Verify boundary
Decode a JWT (header.payload.signature, base64url) and check iss, aud, exp, nbf, scp/roles. Validate the signature against the IdP's JWKS (/.well-known/openid-configuration → jwks_uri).
Never paste production tokens into public decoding sites.
Step 2 Verification path Verify boundary
# Inspect a JWT's header and payload (no signature validation)
python3 -c 'import sys,json,base64; [print(json.dumps(json.loads(base64.urlsafe_b64decode(p+"="*(-len(p)%4))),indent=1)) for p in sys.argv[1].split(".")[:2]]' "$TOKEN"
# Human-readable times
date -d @1767225600
# Keys the issuer currently publishes (match the header's kid)
curl -s https://login.example.com/.well-known/openid-configuration | jq -r .jwks_uri | xargs curl -s | jq -r '.keys[].kid'
Check in order: is it the right type of token for this use (ID vs access), the right issuer, the right audience, still valid (nbf ≤ now < exp, allowing small skew), signed with a known key, and carrying the expected scopes/roles.
Step 3 Troubleshooting Narrow the fault
- 401 from an API: decode the token — usually wrong audience (token for another API), expired, or the API does not trust the issuer/keys.
- 403 with a valid token: scopes or roles missing — consent or role assignment, not authentication.
- Works, then fails after some time: refresh flow broken (refresh token revoked, rotated twice, expired).
- Fails right after the IdP rotated keys: the API cached old JWKS; refresh on unknown
kid.
Step 4 Common mistakes Narrow the fault
- APIs accepting tokens without checking
aud. - Long-lived access tokens; revoke refresh tokens on account compromise.
Evidence · 1 on this Topic
Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.
- SAML assertions, ID tokens, access tokens and refresh tokens have different purposes.
- Every token must be validated.
- Protect tokens in transit and storage.
python3 -c "import jwt,sys;print(jwt.decode(sys.argv[1],options={'verify_signature':False}))" <token>— decode JWT (inspection only)- Token lifetimes — exp policy
- Revocation capability — sessions/refresh tokens
ReferenceWhat it is1 section · depth on demand
Direct Answer
Tokens carry identity and permissions from an identity provider to applications: SAML assertions and OIDC ID tokens say who the user is; OAuth access tokens let a client call an API; refresh tokens get new access tokens. JWTs are signed, readable JSON — validate issuer, audience, expiry and signature, never trust them unvalidated, and keep access tokens short-lived.
ReferenceWhy it matters1 section · depth on demand
Token types
| Token | Format | Used by |
|---|---|---|
| SAML assertion | Signed XML | SP login |
| OIDC ID token | JWT | Client: who the user is |
| OAuth access token | JWT or opaque | API: what the client may do |
| Refresh token | Opaque | Obtain new access tokens |
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
Tokens carry identity and authorisation from an identity provider to clients and APIs, so that passwords are not passed around.
Kinds of token
| Token | Format | Audience | Purpose |
|---|---|---|---|
| SAML assertion | Signed XML | Service provider | Browser SSO login |
| ID token (OIDC) | Signed JWT | Client application | Who the user is and how they authenticated |
| Access token (OAuth 2.0) | JWT or opaque string | API (resource server) | Permission to call the API with given scopes |
| Refresh token | Usually opaque | Authorization server | Get new access tokens without a new login |
| Kerberos ticket | Binary, encrypted | Kerberos service | Windows/AD service access |
JSON Web Tokens (JWT, RFC 7519)
A JWT is header.payload.signature, each part base64url-encoded. The header names the algorithm (alg, e.g. RS256, ES256) and key ID (kid); the payload carries claims (iss, sub, aud, exp, nbf, iat, scp/roles …); the signature (JWS) proves integrity. A JWT is readable by anyone who has it — it is signed, not encrypted, unless JWE is used. Never put secrets in a JWT.
Self-contained vs opaque
- JWT access tokens are validated locally by the API (signature with the issuer's JWKS,
iss,aud,exp, scopes) — fast, but cannot be revoked before expiry, so keep them short-lived. - Opaque tokens are random references; the API asks the authorization server through token introspection (RFC 7662), which allows immediate revocation.
Bearer vs sender-constrained
Most access tokens are bearer tokens: whoever holds one can use it. Sender-constrained tokens are bound to a key the client must prove it holds (mutual TLS, RFC 8705, or DPoP, RFC 9449), so a stolen token is useless elsewhere.
Safe handling (RFC 8725 and OAuth security BCP)
Accept only expected algorithms (never none), validate issuer and audience, keep access tokens short-lived, protect refresh tokens (rotation, secure storage), never log full tokens, and send tokens only over TLS.
ReferenceConfiguration & state1 section · depth on demand
Lifecycle and ownership
| Token | Typical lifetime | Ended by |
|---|---|---|
| Access token | Minutes to about an hour | Expiry (JWT) or revocation via introspection (opaque) |
| ID token | Minutes; used once at login | Expiry; the app's own session lasts longer |
| Refresh token | Hours to months, often sliding | Revocation, rotation, password reset, user disabled, inactivity |
| SAML assertion | Minutes (validity window) | Expiry; SP session separate |
The identity provider owns token lifetimes and signing keys; the application owns its session, token storage and validation. Revoking a user's refresh tokens does not end already-issued access tokens — they live until expiry, which is why access tokens should be short.
Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Verification history & basis
When and against what this Topic was checked. Later text edits do not count as a new check.
Authoritative/upstream documentation reviewed for bounded claims in Single Sign-On & Federation → Tokens. Documentation verification only; this is not observed lab or production Evidence.
Basis: https://www.rfc-editor.org/rfc/rfc7522 · confidence 94%Terms & aliases
Hover a linked term for a quick definition; click it to open its glossary entry. Aliases are other names that find this Topic in search.
Deep reference
Healthy vs suspicious evidence
Output interpretation
| Field | What to look for |
|---|---|
alg / kid (header) | Expected algorithm; kid present in the issuer's JWKS |
iss | Exactly the configured issuer (tenant-specific vs common endpoints differ) |
aud | The API's identifier (access token) or the client ID (ID token) |
exp, nbf, iat | Unix seconds; compare with current UTC time |
scp / scope | Delegated permissions granted to the client |
roles | Application roles (often for app-only tokens) |
azp / appid | Which client obtained the token |
sub / oid | Subject — stable user or service identifier |
typ: at+jwt | Access token per RFC 9068 — must not be accepted as an ID token |