OAuth vs OIDC: authorisation vs authentication, explained with real flows
OAuth 2.0 grants access to APIs; OpenID Connect adds login. Tokens, scopes, flows and the mistakes that come from mixing them up.
OAuth 2.0 is for authorisation: it lets a client get an access token to call an API on a user's behalf. OIDC is for authentication: it adds an ID token that tells the client who the user is and how they logged in. If you need to log users in, use OIDC; if you only need to call an API, OAuth alone is enough. Using a plain OAuth access token as proof of login is the classic mistake OIDC exists to fix.
| OAuth 2.0 | OIDC | |
|---|---|---|
| Question answered | Can this client access this resource? | Who is the user and how did they log in? |
| Spec | RFC 6749, bearer use RFC 6750 | OpenID Connect Core 1.0, built on OAuth 2.0 |
| Main artefact | Access token, optional refresh token | ID token, plus OAuth tokens |
| Token audience | The resource server (API) | The client itself (aud = client_id) |
| Token format | Opaque or JWT (RFC 9068 profile) | Always a JWT |
| Trigger | Any scope, e.g. calendar.read | scope must include openid |
| Replay binding | state for CSRF, PKCE for code | Adds nonce in the ID token |
| User info | Not defined | UserInfo endpoint and standard claims |
| Discovery | RFC 8414 server metadata | /.well-known/openid-configuration |
| Typical consumer | APIs and machine clients | Web, SPA and mobile sign-in |
01How each one works
OAuth 2.0 defines roles (resource owner, client, authorisation server, resource server) and grants for obtaining an access token. The token says what the bearer may do at an API. OAuth deliberately does not say who the user is: the client is not supposed to read the access token, and the token may be opaque.
OIDC reuses the OAuth authorization code flow and adds three things: the openid scope, an ID token addressed to the client, and a UserInfo endpoint. The ID token carries iss, sub, aud, exp, nonce and optionally auth_time, amr and acr, so the client can verify the login cryptographically.
RFC 9700 (OAuth 2.0 Security Best Current Practice, 2025) and the OAuth 2.1 draft both say: use the authorization code flow with PKCE for all clients, drop the implicit and password grants, and use exact redirect URI matching.
02The same flow, with and without OIDC
GET /authorize?response_type=code
&client_id=app123
&redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback
&scope=calendar.read
&state=af0ifjsldkj
&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
&code_challenge_method=S256
Host: auth.example.com
# Token response
{ "access_token": "eyJhbGciOiJSUzI1NiIs...", "token_type": "Bearer",
"expires_in": 600, "refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA", "scope": "calendar.read" }GET /authorize?response_type=code
&client_id=app123
&redirect_uri=https%3A%2F%2Fapp.example.com%2Fcallback
&scope=openid%20profile%20email%20calendar.read
&state=af0ifjsldkj
&nonce=n-0S6_WzA2Mj
&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM
&code_challenge_method=S256
Host: auth.example.com
# Token response now also carries an ID token for the client
{ "access_token": "eyJhbGciOiJSUzI1NiIs...", "token_type": "Bearer",
"expires_in": 600, "id_token": "eyJraWQiOiIxZTlnZGs3IiwiYWxnIjoiUlMyNTYifQ...",
"refresh_token": "tGzv3JOkF0XG5Qx2TlKWIA" }The client validates the ID token (signature, iss, aud, exp, nonce) to log the user in, then sends the access token to the calendar API. The API validates the access token against its own audience and never sees the ID token.
03When to use which
- User sign-in to your app: OIDC. Even if you also need API access, request openid alongside the API scopes.
- Server to server or a background job calling an API: plain OAuth client credentials. There is no user, so there is nothing to authenticate with OIDC.
- Third-party integrations reading user data from your API: OAuth with narrow scopes and consent. Add OIDC only if the integrator also needs to know who the user is.
- Your own API checking callers: validate access tokens (JWT signature or RFC 7662 introspection). Do not accept ID tokens.
04Common mistakes
- Pseudo-authentication with OAuth: calling a profile API with an access token and treating the response as a login. A token issued to another client can be injected; OIDC's aud and nonce checks stop that.
- Sending ID tokens to APIs. Their audience is the client, so an API that accepts them accepts tokens minted for any app on the same provider.
- Skipping PKCE for confidential clients. RFC 9700 recommends it for all clients because it also blocks code injection.
- Long-lived bearer access tokens in browsers. Keep them short, rotate refresh tokens, and consider sender-constrained tokens with DPoP (RFC 9449) or mTLS (RFC 8705).
- Reading identity from the access token because it happens to be a JWT. Its format is between the authorisation server and the API, and can change.
05How to say it in an interview
"OAuth is delegation: an access token tells an API what this client may do. OIDC sits on top and adds an ID token addressed to the client that proves who logged in, bound with aud and nonce. So the app consumes the ID token, the API consumes the access token, and neither should accept the other's."
Questions people ask
Q1Is OAuth an authentication protocol?+
No. OAuth 2.0 is an authorisation framework. Using it for login without OIDC leads to token substitution bugs, which is why OIDC was created.
Q2What is the difference between an ID token and an access token?+
An ID token is a JWT for the client describing the login. An access token is for the API describing what the client may do. Different audiences, different consumers.
Q3Do I need OIDC if I use OAuth?+
Only if you need to know who the user is. Machine to machine API access with client credentials does not need OIDC.
Q4Is OAuth 2.1 a finished standard?+
Not yet. It is an IETF draft that consolidates OAuth 2.0 with its security best practices. You can follow its rules today: PKCE everywhere, no implicit or password grants.
Q5Can an access token be a JWT?+
Yes. RFC 9068 defines a JWT profile for access tokens. Clients should still treat them as opaque; only the API should parse them.