Use this when adding sign-in to apps using OpenID Connect.
OpenID Connect
OpenID Connect (OIDC) adds authentication to OAuth 2.0, returning an ID token with user identity, plus a standard user info endpoint and discovery. It is the common choice for modern SSO.
1. OIDC adds identity (ID token) on top of OAuth 2.0.
2. Validate ID token signature, iss, aud, exp, nonce.
3. Use discovery and JWKS.
4. Userinfo endpoint for claims.
5. Code flow with PKCE.
authorize request (state, nonce, PKCE) → OP authentication → code to redirect_uri → token endpoint exchange → ID token validation (iss, aud, signature/JWKS, exp, nonce) → account mapping (iss + sub) → RP session
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 Known-good, broken and when it is fixed Verify boundary
Known-good requires a fresh login to validate state/nonce, exchange the intended code, validate the ID token against the configured issuer/key set and create the correct local session. Invalid issuer/audience/nonce responses should fail. A valid ID token shows the authentication statement for the client; it does not automatically authorize downstream APIs.
Step 2 Verification path Verify boundary
# 1. Discovery: issuer and endpoints the RP should be configured with
curl -s https://login.example.com/.well-known/openid-configuration | jq '{issuer, authorization_endpoint, token_endpoint, jwks_uri}'
# 2. Signing keys currently published
curl -s "$(curl -s https://login.example.com/.well-known/openid-configuration | jq -r .jwks_uri)" | jq -r '.keys[] | "\(.kid) \(.kty) \(.alg // "-")"'
# 3. Decode an ID token's header and payload (inspection only — this does not validate the signature)
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]]' "$ID_TOKEN"
Compare the decoded iss, aud, exp and nonce with the RP's configuration and request, and the header's kid with the JWKS. Capture the redirect to the authorization endpoint in the browser to check redirect_uri, scope, state and nonce; error redirects carry error and error_description parameters.
Step 3 Common mistakes Narrow the fault
- Not validating
iss,aud,expandnonce— or acceptingalg: none. - Using email instead of
iss+subas the account identifier. - Using the implicit flow or skipping PKCE.
- Hard-coding signing keys instead of following the JWKS.
- Treating the access token as proof of identity in the client (that is the ID token's job).
Step 4 Native failure isolation and next-check logic Narrow the fault
Trace one authorization request with state/nonce through callback handling. Verify discovery issuer/endpoints, redirect URI, authorization code exchange, ID-token signature and iss/aud/exp/nonce claims, then the client account mapping. If the login succeeds but API access fails, inspect the access token/resource-server path separately. If only one tenant/client fails, compare client registration and issuer rather than global authentication health.
Step 5 Failure boundaries Narrow the fault
- Before login: discovery, client registration, redirect URI — errors appear at the OP.
- At login: authentication policy (MFA, Conditional Access) — OP sign-in logs.
- At callback: state/nonce and session handling — RP logs and cookies.
- At token exchange: client authentication, code, PKCE — token endpoint errors.
- After tokens: ID token validation and claim mapping — RP logs; the OP considers the login successful.
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.
- OIDC adds ID tokens and userinfo to OAuth 2.0.
- Discovery document lists endpoints and keys.
- Validate tokens fully.
curl -s https://<idp>/.well-known/openid-configuration | jq .issuer,.jwks_uri— discovery- ID token validation: iss, aud, exp, nonce — checks
curl -s <jwks_uri> | jq '.keys[].kid'— signing keys
ReferenceWhat it is2 sections · depth on demand
Direct Answer
OpenID Connect adds login to OAuth 2.0: after the authorization code flow (with PKCE), the app receives a signed ID token (JWT) describing the user. The app must validate issuer, audience, signature (JWKS), expiry and nonce, and should identify users by iss + sub. Most failures are redirect-URI mismatches, expired client secrets, issuer/audience mismatches and lost state/nonce cookies.
Scope and canonical references
- Underlying framework: OAuth 2.0.
- Tokens: ID Token, Access Token, Refresh Token, Claims.
- SSO alternative: SAML.
- Products: Microsoft Entra ID, Keycloak.
- Fault isolation: Federation Troubleshooting.
ReferenceHow it works1 section · depth on demand
How it works
OpenID Connect layers identity semantics on OAuth 2.0 using an ID token, UserInfo and discovery/metadata. The client relies on issuer, client/audience, nonce/state and signature validation to bind the authentication response to the initiated session. An access token and ID token have different consumers and must not be substituted for each other.
ReferenceImportant terms & boundaries1 section · depth on demand
In depth
OpenID Connect (OIDC) 1.0 is an identity layer on top of OAuth 2.0. The client (relying party, RP) sends the user to the OpenID Provider (OP) with scope=openid; after login the RP receives an ID token — a signed JWT stating who the user is and how they authenticated — and usually an access token for APIs. OIDC is the default for new applications, mobile apps and modern SaaS.
Authorization code flow (recommended)
1. RP redirects the browser to the OP's authorization endpoint with response_type=code, client_id, redirect_uri, scope=openid profile email, state, nonce and a PKCE code_challenge.
2. The user authenticates at the OP (password, MFA, passkey, existing session) and consents if required.
3. The OP redirects back to redirect_uri with a one-time code and the same state.
4. The RP's back end exchanges the code (with code_verifier and client authentication) at the token endpoint and receives id_token, access_token and optionally refresh_token.
5. The RP validates the ID token and creates its session.
The implicit flow (tokens in the redirect) is discouraged; use the code flow with PKCE for browser and mobile apps too.
ID token claims
| Claim | Meaning |
|---|---|
iss | Issuer — exact match with the configured OP |
sub | Stable, unique user identifier at this issuer (use it, with iss, as the account key — not email) |
aud | Audience — must contain the RP's client_id |
exp, iat | Expiry and issue time |
nonce | Must equal the nonce the RP sent (replay protection) |
auth_time, acr, amr | When and how the user authenticated (e.g. MFA) |
azp | Authorised party when there are several audiences |
Validation (OpenID Connect Core 1.0)
The RP must check the issuer exactly, that aud contains its client ID, the signature using the algorithm in the token header and the OP's published keys (JWKS, selected by kid), that the token has not expired, and that nonce matches. Reject alg: none and unexpected algorithms.
Discovery and keys
Every OP publishes /.well-known/openid-configuration with its issuer, endpoints (authorization, token, userinfo, end_session) and jwks_uri. OPs rotate signing keys; RPs should fetch the JWKS dynamically and cache it, refreshing when an unknown kid appears.
Other pieces
- UserInfo endpoint returns claims for an access token.
- Scopes
profile,email,address,phonerequest standard claims;offline_accessrequests a refresh token. - Logout: RP-initiated logout via the
end_session_endpoint; front-channel and back-channel logout notify RPs.
OIDC vs SAML
Both give SSO. OIDC uses JSON/JWT, works naturally for SPAs, mobile and APIs, and has discovery; SAML is XML, browser-POST based and still dominant in older enterprise applications. Many IdPs (Microsoft Entra ID, Keycloak) offer both.
ReferenceConfiguration & state1 section · depth on demand
Lifecycle and ownership
- Client registration: client ID, client type (confidential with secret/certificate, or public with PKCE), exact redirect URIs, allowed scopes and grant types.
- Secrets and keys: client secrets expire — track them, prefer certificates or private-key JWT; the OP's signing keys rotate and RPs must follow the JWKS.
- Claims: agree on which claims the app uses for identity (
iss+sub) and authorisation (groups, roles); changing them breaks mapping. - Offboarding: disable the client registration and revoke its tokens; deprovision app accounts (see SCIM).
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 → OpenID Connect. 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
| Error / observation | Meaning |
|---|---|
redirect_uri_mismatch / invalid_redirect_uri | Redirect URI not registered exactly (scheme, host, port, path, trailing slash) |
invalid_client at the token endpoint | Wrong client ID/secret, expired secret, or wrong client authentication method |
invalid_grant | Code expired, already used, PKCE verifier mismatch, or redirect URI differs from the authorize request |
invalid_scope | Scope not allowed for this client |
| RP: issuer mismatch | Configured issuer differs from iss (trailing slash, tenant-specific vs common endpoint, Keycloak hostname) |
| RP: audience mismatch | Token was issued for another client ID |
| RP: signature/kid not found | RP cached old keys after rotation, or uses the wrong JWKS |
| RP: nonce/state mismatch | Session cookie lost between redirect and callback (SameSite, multiple instances without shared session) |
| Token valid but expired immediately | Clock skew between OP and RP |