Drawing 1 · Interactive
Access or identity: which one do you need?
Compared on
OAuth 2.0
Delegates access: what may this app do?
OpenID Connect
Adds identity: who just signed in?
- OAuth 2.0May this app call this API?OpenID ConnectWho is the user, and when did they authenticate?
- OAuth 2.0Access token, sent to the APIOpenID ConnectID token, read by your app
- OAuth 2.0Opaque or JWT, up to the serverOpenID ConnectAlways a signed JWT
- OAuth 2.0Any scopes, e.g. whatsapp_business_messagingOpenID ConnectThe openid scope (plus email, profile)
- OAuth 2.0The resource server or APIOpenID ConnectYour client_id
- OAuth 2.0state and PKCEOpenID Connectstate, PKCE and a nonce inside the ID token
- OAuth 2.0Embedded Signup granting WABA accessOpenID ConnectAgents signing in to the team inbox via SSO
Verdict
Use OAuth when an app must act on someone's account; add OpenID Connect when the app must know who the person is.
Verdict: Use OAuth when an app must act on someone's account; add OpenID Connect when the app must know who the person is.
What is OpenID Connect (OIDC)?
OpenID Connect (OIDC) is an identity layer built on top of OAuth 2.0. Where OAuth only delegates access ("this app may call that API"), OIDC also authenticates: the identity provider returns an ID token, a signed JSON Web Token (JWT) stating who the user is (sub), who issued the statement (iss), which app it is for (aud), when the person authenticated (auth_time) and when the token expires (exp). OpenID Connect Core 1.0 was finalised by the OpenID Foundation in 2014 and sits behind most sign-in-with buttons and modern Single Sign-On (SSO).
The flow is an OAuth authorisation code flow with additions. The app adds openid to the scope (plus email or profile if it needs those claims), a random nonce and ideally PKCE. After the user authenticates at the identity provider, the app exchanges the code at the token endpoint and receives an id_token alongside the access_token. Providers publish their endpoints and signing keys in a discovery document at /.well-known/openid-configuration, so clients can find the jwks_uri they need to verify signatures.
For a business running WhatsApp at scale, OIDC usually appears in two places: staff signing in to the messaging dashboard or team inbox with their company identity provider, and customer apps offering sign-in with an existing account. It is not how Embedded Signup works; that flow uses OAuth to grant access to WhatsApp assets, not to start a user session. Compared with Security Assertion Markup Language (SAML), OIDC uses compact JSON tokens over plain HTTPS redirects, which suits mobile and single-page apps.
Key takeaways
- OpenID Connect (OIDC) is an identity layer on OAuth 2.0: it tells your app who signed in through a signed ID token.
- Adding the
openidscope turns an OAuth authorisation request into an OIDC sign-in. - Validate every ID token: signature against the provider's JWKS, then
iss,aud,expand thenonceyou sent. - Use the ID token to sign the user in and the access token to call APIs, never the other way round.
- OIDC is the modern default for staff single sign-on to messaging dashboards; SAML remains common in older enterprise setups.
Specifications
OpenID Connect (OIDC): key facts and limits
- Built on
- OAuth 2.0 authorisation code flow
- What turns it on
openidin the scope parameter- Identity proof
- ID token: always a signed JWT
- Claims to check
- Signature, iss, aud, exp, nonce
- Discovery document
- /.well-known/openid-configuration
- Stable user key
- iss + sub (sub is unique per issuer)
- Specification
- OpenID Connect Core 1.0 (2014)
Operating sequence
How does OpenID Connect (OIDC) work?
Register the client
Register your app with the identity provider to get a
client_id(and a secret for server-side apps), and allow-list the exactredirect_urithe provider may send users back to.Send an authentication request
Redirect to the
authorization_endpointwithresponse_type=code,scope=openid email, a randomstate, a randomnonceand a PKCEcode_challenge.Exchange the code
On the callback, check
state, then POST the code and thecode_verifierto thetoken_endpoint. The response holds anid_token, anaccess_tokenand often arefresh_token.Validate the ID token
Verify the signature with a key from the provider's
jwks_uri, then check thatissequals the issuer,audcontains yourclient_id,expis in the future andnoncematches the value you stored.Create your own session
Map the stable
iss+subpair (not the email) to a user record, start your app's session, and keep the access token for calls to the provider's APIs or its UserInfo endpoint.
Implementation
OpenID Connect (OIDC) in code
import { createRemoteJWKSet, jwtVerify } from "jose";// Read the issuer's endpoints from its discovery document once at start-up.const ISSUER = "https://login.example-idp.com";const discovery = await fetch(`${ISSUER}/.well-known/openid-configuration`).then((r) => r.json());const JWKS = createRemoteJWKSet(new URL(discovery.jwks_uri)); // cached, refetched on unknown kidexport async function verifyIdToken(idToken, expectedNonce) {// Checks the signature, iss, aud and exp in one call.const { payload } = await jwtVerify(idToken, JWKS, {issuer: ISSUER,audience: process.env.OIDC_CLIENT_ID,clockTolerance: 60, // seconds of allowed clock skew});if (payload.nonce !== expectedNonce) throw new Error("nonce mismatch");return { issuer: payload.iss, subject: payload.sub, email: payload.email };}
Use a maintained JOSE library: hand-rolled JWT parsing is where most ID-token bugs come from.
Failure modes
Common mistakes with OpenID Connect (OIDC)
Using the access token as proof of identity
An access token is meant for an API: your app may not be its audience, and it may not even be a JWT. Sign users in from a validated ID token whose
audis your client.Decoding without verifying
Base64-decoding the ID token and reading
emailskips the signature, issuer and audience checks, so anyone can forge a token. Verify against the provider's JWKS with a maintained library.Keying users by email
Email addresses change and can be reassigned to someone else. Use the
iss+subpair as the stable identifier, and treat email as a profile attribute (checkemail_verified).Skipping state and nonce
Without
statethe callback is open to login CSRF; withoutnonce, a captured ID token can be replayed into a new session. Generate both per request and compare them on return.
OIDC FAQs
What is the difference between OAuth and OpenID Connect?+
Is an ID token the same as a JWT?+
Should I choose OIDC or SAML for single sign-on?+
Does WhatsApp Embedded Signup use OpenID Connect?+
Design intent
Why does OpenID Connect (OIDC) matter?
Sign-in is where most account takeovers begin. Building your own password login for a messaging dashboard means storing hashes, adding MFA and handling resets, and every leaver keeps working credentials until someone remembers to delete them. With OIDC the identity provider handles authentication and Two-Factor Authentication, your app receives a verifiable statement of who signed in, and disabling a person in the directory removes their access everywhere at once, which is exactly what auditors look for when agents can read customer chats.
Example: SSO for a 60-agent support team in Kochi
A travel company in Kochi runs WhatsApp support from a 60-seat inbox. Agents used to have separate passwords, and two former agents still had working logins months after leaving. The team switches the inbox to OIDC with the company's identity provider: agents click "Sign in with company account", the provider enforces MFA, and the inbox validates the ID token and maps sub to the agent's profile and role. When someone leaves, HR disables their directory account and the next sign-in attempt fails, with no inbox admin needing to remember anything.
Recommended practice
Best practices for OpenID Connect (OIDC)
- Cache the JWKS but refetch on an unknown
kid, so provider key rotation never breaks sign-in. - Allow a small clock skew, a minute or so, when checking
expandiat. - Request only the claims you use;
openid emailis enough for most dashboards. - Map directory groups to dashboard roles at sign-in, so access follows the person's job.