The login layer on top of OAuth2: it tells an app who the user is.
OpenID Connect (OIDC) is a thin login layer on top of OAuth 2.0. OAuth answers “what may this app do?”. OIDC adds the missing answer to “who just logged in?”.
OAuth 2.0 was designed to give an app access to something. It never promised to tell the app who the user is. Many apps used OAuth for login anyway, each in its own way, and that led to bugs and attacks.
OIDC fixes this by standardising login. It reuses the OAuth flows, and adds a few things: the openid scope, the ID token, a UserInfo endpoint for more profile data, and a discovery document so apps can configure themselves.
It is a JWT with three parts (header, payload, signature). The payload holds claims. These are made-up example values:
{
"iss": "https://login.example.com", // who issued it
"sub": "user-8421", // the user's stable id
"aud": "my-app", // the app it was made for
"exp": 1767225600, // when it stops being valid
"iat": 1767225300, // when it was issued
"nonce": "n-7f3a", // ties it to one login attempt
"email": "ada@example.com" // optional profile claim
}| Part | What it is | Why it matters |
|---|---|---|
| openid scope | A special scope the app adds to the request | Tells the provider “this is a login”, so an ID token is returned. |
| ID token | A signed JWT about the login | The proof of who logged in. Validated by the app. |
| UserInfo endpoint | An API that returns profile claims for an access token | Keeps the ID token small. Use it for extra details. |
| Discovery document | JSON at /.well-known/openid-configuration | Lists the endpoints and the key location, so setup is automatic. |
| JWKS | The provider’s public signing keys, as a JSON set | Used to check the ID token signature. Keys rotate over time. |
| Standard scopes | profile, email, address, phone | Ask only for the claims you really need. |
| Flow | Use it? | Notes |
|---|---|---|
| Authorization code + PKCE | Yes, the default | Works for server apps, single-page apps and mobile apps. |
| Authorization code (with a client secret) | Yes, for server-side apps | The secret stays on your server, never in browser or mobile code. |
| Implicit flow | No, avoid | Returns tokens in the browser address bar. Older and weaker. Replaced by code + PKCE. |
| Password grant | No, avoid | The app handles the user’s password. This is what OAuth was made to prevent. |
A simplified teaching model. Names, addresses and values are made-up examples. Real providers add more checks, such as the issued-at time, the signing algorithm and the key id.
| Term | Meaning in easy words |
|---|---|
| OpenID Connect (OIDC) | A login standard built on top of OAuth 2.0 |
| Identity provider (OP) | The service that logs the user in and issues tokens (Okta, Google, Keycloak) |
| Relying party (RP) | The app that relies on the provider to know who the user is |
| ID token | A signed JWT that says who logged in and how. Meant for the app |
| Access token | A token used to call APIs. Not proof of identity |
| Claim | One fact inside a token, such as sub, email or exp |
| sub | The user’s stable, unique id at that provider |
| Nonce | A random value that ties an ID token to one login attempt, to stop replay |
| PKCE | A one-time secret that stops a stolen authorization code from being used |
| Discovery document | A JSON file listing the provider’s endpoints and settings |
| JWKS | The provider’s set of public keys used to check token signatures |
| Choice | We gain | We lose |
|---|---|---|
| OIDC provider (hosted) | Security work, MFA and passkeys done for you | Another vendor, cost and an outside dependency |
| Run your own provider (Keycloak etc.) | Full control of data and settings | You run, patch and secure a critical service |
| ID token only | Simple, no extra calls | Token may be large or lack the claims you need |
| ID token + UserInfo | Fresh and detailed profile data | One more network call per login |
| Short token lifetime | A stolen token is useful for less time | More refreshes and more load on the provider |