Skip to content

OAuth 2.0 vs OpenID Connect (OIDC) - What's the Difference?

Protocol Comparison

OAuth 2.0 vs OIDC

READING TIME
12 minutes
DIFFICULTY
Intermediate
THE KEY DISTINCTION
OAuth 2.0 is for Authorization (what can you access?). OpenID Connect is for Authentication (who are you?). OIDC is an identity layer built on top of OAuth 2.0.
The Nightclub Analogy: OAuth 2.0 is like showing a wristband that proves you paid for VIP access—the bouncer doesn’t care who you are, just that you have access. OpenID Connect is like showing your driver’s license—the bouncer now knows your name, age, and photo, confirming your identity before granting VIP access.
AspectOAuth 2.0OpenID Connect (OIDC)
PurposeAuthorizationAuthentication + Authorization
Question Answered”What can this app access?""Who is this user?”
Token TypeAccess TokenID Token + Access Token
Token FormatOpaque or JWTJWT (always)
User InfoOptional (via API call)Built-in (ID Token claims)
Use CaseAPI access, third-party integrationsSingle Sign-On, user login
SpecificationRFC 6749, RFC 6750OpenID Foundation spec

OAuth 2.0 was designed to solve the delegated authorization problem. Before OAuth, if you wanted a third-party app to access your data, you had to give it your password.

Imagine you want a photo printing service to access your Google Photos. Without OAuth:

  1. ❌ Give the printing service your Google password
  2. ❌ The service has full access to your entire Google account
  3. ❌ You can’t revoke access without changing your password
  4. ❌ If the service is compromised, your entire account is at risk

With OAuth 2.0:

  1. ✅ You authorize specific, limited access (only photos, not email)
  2. ✅ The service receives a token, never your password
  3. ✅ You can revoke access at any time
  4. ✅ Tokens can expire automatically
1

Authorization Request

User clicks “Connect with Google.” App redirects to Google’s authorization server with requested scopes (e.g., “read photos”).

2

User Consent

User logs into Google (if needed) and sees a consent screen: “Photo Printer wants to access your photos. Allow?“

3

Authorization Code

User approves. Google redirects back to the app with a short-lived authorization code.

4

Token Exchange

App exchanges the authorization code for an Access Token (server-to-server, secure).

5

API Access

App uses the Access Token to call Google Photos API. Token proves authorization, not identity.

OAuth 2.0 has a critical limitation: it doesn’t tell you WHO the user is.

Access Token: "ey...abc123"
Meaning: "Bearer of this token can read photos"
Missing: Who is the user? What's their name? Email? User ID?

This is where OpenID Connect comes in.

OpenID Connect (OIDC) extends OAuth 2.0 by adding an identity layer. It answers the question: “Who is this user?”

OAuth 2.0 ComponentOIDC Addition
Access TokenID Token (user identity)
Scopes (read, write)openid, profile, email scopes
Token endpointUserInfo endpoint
-Discovery document (.well-known/openid-configuration)
-Standard claims (sub, name, email, picture)

The ID Token is a JWT (JSON Web Token) containing claims about the authenticated user:

{
"iss": "https://accounts.google.com",
"sub": "110248495921238986420",
"aud": "your-client-id.apps.googleusercontent.com",
"exp": 1735142400,
"iat": 1735138800,
"name": "Jane Developer",
"email": "jane@example.com",
"email_verified": true,
"picture": "https://lh3.googleusercontent.com/..."
}

Key claims:

  • iss: Who issued this token (Google, Okta, Auth0, etc.)
  • sub: Unique identifier for the user
  • aud: Which app this token is for (prevents token misuse)
  • exp/iat: Expiration and issued-at timestamps
  • name, email, picture: User profile information

OIDC uses the same flow as OAuth 2.0, with key differences:

1

Authorization Request with OIDC Scopes

Include openid scope (required), plus profile and email as needed.

2

Token Exchange Returns ID Token

Server returns both an Access Token and an ID Token.

3

Validate the ID Token

Verify signature, check issuer, audience, expiration. The ID Token is cryptographically signed proof of identity.

4

Optional: UserInfo Endpoint

For additional claims not in the ID Token, call the UserInfo endpoint with the Access Token.

OAuth 2.0 alone is sufficient when you need:

  • ✅ API access without user identity (machine-to-machine)
  • ✅ Third-party integrations (Slack posting to your channel)
  • ✅ Access delegation without login
  • ✅ Service-to-service communication

Example: A scheduling app that posts to your Google Calendar. It doesn’t need to know who you are—just that you authorized calendar access.

OAuth 2.0 Implementation Guide →

❌ Mistake 1: Using Access Tokens for Authentication

Section titled “❌ Mistake 1: Using Access Tokens for Authentication”
// WRONG - Never trust access tokens for identity
const user = await getUserFromAccessToken(accessToken);

Access tokens are for API access, not identity. Always validate the ID Token for user identity.

// WRONG - Never skip validation
const claims = jwt.decode(idToken); // Just decodes, no verification!
// RIGHT - Always verify signature
const claims = jwt.verify(idToken, publicKey, { algorithms: ['RS256'] });

❌ Mistake 3: Ignoring the Audience Claim

Section titled “❌ Mistake 3: Ignoring the Audience Claim”

ID tokens are minted for specific clients. If your client_id isn’t in the aud claim, reject the token.

Token TypeBrowser StorageRecommendation
Access Token❌ localStorage✅ Memory only, or httpOnly cookie
ID Token❌ localStorage✅ Validate and discard, or httpOnly cookie
Refresh Token❌ NEVER in browser✅ Server-side only
ProtocolSpecificationKey Documents
OAuth 2.0IETF RFC 6749RFC 6749, RFC 6750
OAuth 2.1DraftConsolidates OAuth 2.0 best practices
OpenID ConnectOpenID FoundationCore Spec
PKCERFC 7636Required for public clients
DPoPRFC 9449Sender-constrained tokens

OAuth 2.0 Deep Dive

Master all OAuth 2.0 flows: Authorization Code, Client Credentials, and more. OAuth 2.0 Guide →

OpenID Connect Deep Dive

Learn ID Token validation, discovery, and session management. OIDC Guide →

Implement SSO

Put it all together with a Single Sign-On implementation. SSO Patterns →

Secure Your Tokens

Learn about PKCE, DPoP, and token security best practices. Token Security →


Master Identity Protocols

Explore our complete protocol documentation including SAML, LDAP, Kerberos, and WebAuthn.