Skip to content

Interview question · Identity, OAuth & Access Control

What is the difference between OpenID Connect and OAuth, and between an ID token and an access token?

Every candidate knows OIDC is 'OAuth plus identity'. Fewer can say which token goes where, and what breaks when they swap.

mediumEssentialNewPreparation tags: Google, Microsoft, SalesforceUpdated Nov 2026

TL;DR: OAuth 2.0 is delegated authorization: it gives a client an access token to call an API on a user's behalf. OpenID Connect adds authentication: with the openid scope the client also receives an ID token, a signed JWT stating who the user is, issued for that client (aud), with expiry and a nonce. ID tokens are for the client to establish a login; access tokens are for APIs. Using one as the other causes account takeover and replay bugs.

How to approach it

Contrast purpose, audience and format for the two tokens, then show the two classic confusions as concrete attacks. End with the validation checklist for ID tokens.

A strong answer

FIG · OAUTH VERSUS OIDC · TWO TOKENS, TWO AUDIENCES
Access tokens are for APIs; ID tokens are for the client

Access token (OAuth)

Client

carries it

API

the audience

Checks scope and audience

Outcome, safe: Delegated authorisation

Says what the client may do, not who the user is

ID token (OpenID Connect)

Auth server

signs it

Client

the audience

Checks iss, aud, exp, nonce

Outcome, safe: Authentication of the user

Never send it to APIs as a credential

ID token (OIDC)Access token (OAuth)
Question it answersWho logged in to this client?May the bearer call this API?
AudienceThe client (aud = client ID)The resource server
FormatAlways a signed JWTOpaque or JWT; clients should treat it as opaque
Consumed byThe client, once, to create a sessionAPIs, on every call
Key claimsiss, sub, aud, exp, iat, nonce, optionally acr/amrScopes, audience, expiry (format varies)

Confusion 1: login with an access token. An app accepts any valid access token from the provider and calls the profile endpoint to identify the user. A malicious app that integrates with the same provider can replay its users' access tokens to this app and log in as them, because the access token was never meant to prove identity to this app. The fix is OIDC: validate an ID token whose aud is your client ID.

Confusion 2: APIs that accept ID tokens. An API treats ID tokens as bearer credentials. Any client the user has logged into holds an ID token for that user and could call the API with it. APIs should accept access tokens issued for them, checked by audience and scope.

Validating an ID token. Verify the signature with keys from the provider's JWKS endpoint using an algorithm fixed in configuration; check iss exactly; check aud contains your client ID (and azp if multiple audiences); check exp and iat; check nonce matches the one stored for this login; and key the account on iss plus sub, never on email alone.

After validation. Create the application's own session (an HttpOnly cookie); do not keep re-sending the ID token. Use the refresh token or re-authentication for longer sessions.

What interviewers probe next

  • "Can the client read claims from the access token?" It should not rely on them; the format belongs to the authorization server and API and may change or be encrypted.
  • "Why key accounts on sub rather than email?" Emails change, can be reassigned and are sometimes unverified; sub is stable per issuer.
  • "How does SAML compare?" Same goal as OIDC for enterprise SSO, using signed XML assertions; similar validation pitfalls around audience, signatures and replay.

What if?

What if · interview follow-ups

Hold your answer as the constraints change

A team uses an OAuth access token from Google to decide who is logged in to their web app, by calling a profile API with it.

  1. Start here

    What is the difference between OAuth and OpenID Connect?

How it's scored

Weak: Says OIDC and OAuth are the same, or that the ID token is used to call APIs.

Hire: Distinguishes authorization from authentication and the two tokens' audiences correctly.

Strong Hire: Explains both confusion attacks, gives the full ID token validation list, and keys accounts correctly.

Common mistakes

  • Implementing "login" with OAuth access tokens alone.
  • Skipping the aud or nonce check.
  • Accepting the token's alg header instead of a configured algorithm.
  • Linking accounts across providers by email.
You just read a free answer. Every topic opens its first 5 answers to anyone. Sign in and the count per topic goes to 10, and we keep track of how far you get in every topic.Google sign-in · free · no payment details
HOW DID IT GO?
0
READING SIGNED OUT

Signing in doubles your free answers, from 5 to 10 per topic, and the site starts remembering you: mastery per topic, bookmarks, and a next-focus recommendation. Free, no card.

Sign in free
UP NEXT ON YOUR JOURNEY
DISCUSSION · 0

No comments yet. Share a correction or a different way to answer it.