OAuth 2.0 gives an app an access token for an API. It doesn't tell the app who the user is. Teams used to call a profile API and treat the result as a login, which was easy to get wrong. OpenID Connect fixes this with a standard ID token: a signed JSON Web Token (JWT) in which the identity provider states who the user is, which app the token is for and when they authenticated. OpenID Connect Core 1.0 was finalised by the OpenID Foundation in February 2014. In 2024 it and eight related OIDC specifications were also published as ISO/IEC standards (Core is ISO/IEC 26131:2024).
How OIDC works
OIDC reuses the OAuth authorization code flow, with three additions:
- The client adds
openidto the scopes (often withprofileandemail) and sends anonce. - The token response includes an
id_tokenalongside the access token. - The client validates the ID token before trusting it.
Clients find the provider's endpoints and signing keys through discovery at
/.well-known/openid-configuration, so the same code works with Google, Microsoft Entra ID, Okta, Auth0, Keycloak or Cognito.
Example: decoding an ID token
A B2B SaaS app lets a customer's staff sign in with their company's Microsoft account. After the redirect, the app receives an ID token whose payload decodes to:
{
"iss": "https://login.microsoftonline.com/7c1e…/v2.0",
"sub": "AAAAAAAAAAAAAAAAAAAAAIkzqFVrSaSaFHy782bbtaQ",
"aud": "3f8b2a10-saas-app-client-id",
"exp": 1795262400,
"iat": 1795258800,
"nonce": "n-0S6_WzA2Mj",
"email": "priya@customer.example"
}
The app checks the signature against the provider's published keys, then that iss is the expected tenant, aud is its own client ID, exp hasn't passed and nonce matches the one it sent. Only then does it look up the user by iss plus sub, the stable identifier, and start a session. It doesn't key accounts on email, which can change or be reassigned.
OIDC vs OAuth 2.0
| OAuth 2.0 | OpenID Connect | |
|---|---|---|
| Question answered | What may this app access? | Who is this user? |
| Main output | Access token for an API | ID token for the client |
| Typical use | API integrations, delegated access | Login, single sign-on |
| OIDC is OAuth with an identity layer. Every OIDC provider is an OAuth authorization server. |
OIDC vs SAML
Both give enterprise single sign-on. SAML 2.0 (2005) uses signed XML assertions passed through the browser, and is still common in corporate identity providers and older enterprise apps. OIDC uses JSON and JWTs and works naturally with mobile apps, single-page apps and APIs. New products usually start with OIDC and add SAML when enterprise customers ask for it.
Common mistakes
- Accepting an ID token without checking
aud, so a token issued to another app logs a user in. - Sending the ID token to your API as an access token. APIs should accept access tokens.
- In multi-tenant apps, accepting any Entra ID or Google tenant when you meant to allow only the customer's.
- Linking accounts by email address alone. Enterprise SSO is often a requirement in security reviews. See Clerk vs Auth0 vs Cognito vs Keycloak for providers that handle it.