top of page

OAuth vs OpenID Connect (OIDC): What’s the Difference?

Writer: Chandan Rajpurohit
Chandan Rajpurohit
13 hours ago
7 min read

If you've worked with modern authentication, you've probably encountered terms like OAuth, OAuth 2.0, OpenID Connect, OIDC, access tokens, ID tokens, and authorization codes.

They are closely related, but they solve different problems.


One of the most common misconceptions is:

"OAuth and OpenID Connect are basically the same authentication protocol."

They're not.


OAuth is primarily an authorization framework. OpenID Connect (OIDC) is an identity and authentication layer built on top of OAuth 2.0.



Today, we'll break down OAuth and OIDC, explain how they work, compare their tokens and flows, and show when you should use each one.


Table of Contents


OAuth vs OIDC at a Glance


The easiest way to understand the difference is:

Feature

OAuth 2.0

OpenID Connect (OIDC)

Primary purpose

Authorization

Authentication + identity

Main question

"What can this application access?"

"Who is this user?"

Access token

Yes

Yes

ID token

No

Yes

User identity

Not standardized

Standardized

Built on

Authorization framework

OAuth 2.0

Common use

API authorization

Login / Sign in

Example

Allow an app to access your calendar

Sign in with Google

The key distinction is:

OAuth tells an application what it is allowed to access.

OIDC tells an application who the user is.


What is OAuth?


OAuth (Open Authorization) is an authorization framework.


It allows a user to grant an application limited access to resources without giving the application their password.


For example, imagine an application wants to access your Google Calendar.


Instead of giving the application your Google password, you authorize it through Google's authorization server.


The application receives an access token. That token can then be used to access permitted resources.


The simplified flow looks like this:


Simplified OAuth Flow
Simplified OAuth Flow

The important point is that OAuth is about delegated authorization.


What Problem Does OAuth Solve?


Imagine you have a photo application that wants to access a user's photos.


Without OAuth, the application might ask for the user's username and password.


That's a terrible security model.


With OAuth:


Photo App OAuth Flow
Photo App OAuth Flow

The photo application never needs the user's password.


The access token can also be limited by:

  • Scope

  • Lifetime

  • Audience

  • Permissions


For example: scope = photos.read


The application may be allowed to read photos but not delete them.


What is OIDC?


OIDC (OpenID Connect)  is an identity protocol built on top of OAuth 2.0.


While OAuth answers:

"What is this application allowed to access?"

OIDC answers:

"Who is the user?"

OIDC adds standardized authentication capabilities to OAuth.


It introduces concepts such as:

  • ID tokens

  • UserInfo endpoint

  • Standard claims

  • Issuer

  • Subject identifier

  • Nonce

  • Authentication requests


This makes OIDC particularly useful for implementing Sign in with... functionality.


For example:


OIDC Flow
OIDC Flow

The application can then establish an authenticated session for the user.


What Does OIDC Add to OAuth?


OAuth by itself doesn't standardize how an application should identify the user.


OIDC adds that missing identity layer.


The most important addition is the ID token.


An ID token is typically a JSON Web Token (JWT) containing information about the authentication event and the authenticated subject.


A simplified payload might look like:

{
  "iss": "https://identity.example.com",
  "sub": "sub-id",
  "aud": "client-id",
  "exp": 1730000000,
  "iat": 1729996400
}

These claims provide standardized information about the identity provider, user, client, and token lifetime.


Access Token vs ID Token


This is one of the most important concepts to understand.


Access Token

An access token is used to access a protected resource.


For example: Application → Access Token → User API


The API validates the access token and determines whether the request is authorized.


Think:

Access token = permission to access something

ID Token

An ID token is used by the client to understand the result of an authentication event.


For example: Identity Provider → ID Token → Your Application → Authenticated User


Think:

ID token = information about who authenticated

This distinction is critical.


Don't use an ID token as an API access token.


An ID token is intended for the client application.

An access token is intended for the protected resource/API.


Let's build Task Manager


Suppose you build a web application called TaskManager. You want users to log in using their Google account.


The architecture could look like:


Task Manager App Arch
Task Manager App Arch

Here:

OIDC handles the user's authentication and identity.

OAuth handles authorization to APIs.


OAuth is Not "Login"


This distinction is worth repeating.


You may see applications saying:

"Login with OAuth."

Technically, this is often inaccurate.


OAuth itself wasn't designed as a user authentication protocol. OAuth allows a client to obtain authorization to access protected resources.


If you want standardized authentication and identity, OIDC is the appropriate layer.


That's why modern identity providers commonly support OIDC.


OAuth + OIDC: How They Work Together


OIDC doesn't replace OAuth.


Instead OIDC uses OAuth mechanisms and adds identity-specific functionality: OpenID Connect → OAuth 2.0 → Authorization Framework


OIDC uses OAuth mechanisms and adds identity-specific functionality.


A typical OIDC authorization request might include:

response_type=code
client_id=my-client
redirect_uri=https://app.example.com/callback
scope=openid profile email
state=...
nonce=...

Notice the: scope=openid


The openid scope is particularly important. It indicates that the request is an OIDC authentication request.


What is the openid Scope?


The openid scope distinguishes an OIDC request from an ordinary OAuth authorization request.


For example: scope=openid profile email

means the application is requesting OIDC authentication along with access to standardized identity claims.


Common OIDC scopes include:

  • openid

  • profile

  • email

  • address

  • phone

The exact claims returned depend on the provider and requested scopes.


OAuth Scopes vs OIDC Scopes


OAuth scopes generally describe permissions.


For example:

calendar.read

calendar.write

photos.read


They answer:

"What can this application access?"

OIDC scopes can request identity-related claims.


For example:

openid

profile

email


They help answer:

"What identity information should be returned?"

What is an Identity Provider?


An Identity Provider (IdP) is a system that authenticates users and provides identity information to applications.


Examples include enterprise identity platforms and social login providers.


Instead of every application implementing its own authentication system, applications can delegate authentication to an identity provider.


OAuth Roles


OAuth commonly involves four major roles.


1. Resource Owner

Usually the user who owns the protected data.


2. Client

The application (Web Application, Mobile Application, Backend Service) requesting access.


3. Authorization Server

The server that issues authorization-related tokens.


4. Resource Server

The API that contains the protected resources.


OIDC Adds an Identity Provider Role


In OIDC, the authorization server also provides identity information.


The provider can expose:

  • Authorization Endpoint

  • Token Endpoint

  • UserInfo Endpoint

  • JWKS Endpoint

  • Discovery Endpoint


The application can use these endpoints to implement standardized authentication.


Authorization Code Flow


The Authorization Code Flow is one of the most important OAuth/OIDC flows.


The simplified sequence is:


Authorization Code Flow
Authorization Code Flow

For browser-based applications, Authorization Code Flow with PKCE is a common modern pattern.


What is PKCE?


PKCE stands for:

Proof Key for Code Exchange.


It helps protect authorization code flows, particularly for public clients such as mobile applications and browser-based applications.


The basic idea is:


PKCE Flow
PKCE Flow

Later, when exchanging the authorization code:

Authorization Code + code_verifier → Token Endpoint


The authorization server verifies that the verifier corresponds to the original challenge.


This helps prevent an intercepted authorization code from being useful to an attacker.


OAuth 2.0 vs OIDC Example


Let's say you build an application that needs access to a user's calendar.


OAuth

Your application asks:

"Can I access this user's calendar?"

The user grants permission.


Your application receives: Access Token


The application can use it to call the calendar API.


OIDC

Now suppose you want the user to sign into your application.


Your application asks:

"Who is this user, and did they successfully authenticate?"

OIDC provides an authentication mechanism and an ID token.


The application can establish an authenticated session based on the validated OIDC response.


OpenID vs OpenID Connect


There is another source of confusion.


OpenID and OpenID Connect are not the same protocol.


OpenID was an earlier identity protocol.

OpenID Connect is a newer identity layer built on OAuth 2.0.


If you're building a new application, you will generally encounter OpenID Connect, not the older OpenID protocol.


Common OAuth and OIDC Mistakes


Mistake 1: Calling OAuth an Authentication Protocol

OAuth is primarily about authorization. For authentication, use an appropriate identity protocol such as OIDC.


Mistake 2: Using an ID Token to Call an API

Don't automatically send an ID token as: Authorization: Bearer <id-token>

An API should receive an access token intended for that API.


Mistake 3: Assuming Every Access Token is a JWT

Access tokens aren't required to have one universal format. They can be opaque strings or structured tokens. Don't build your security model around the assumption that every access token is a JWT.


Mistake 4: Trusting Token Claims Without Validation

A JWT-looking token isn't automatically trustworthy. Applications must properly validate relevant security properties, including things such as:

  • Signature

  • Issuer

  • Audience

  • Expiration

  • Nonce where applicable

  • Appropriate token type/context


Mistake 5: Using OAuth Without Understanding Redirect URIs

Redirect URIs are a critical part of authorization flows.

They should be carefully registered and validated.

Loose redirect URI handling can create serious security vulnerabilities.


OAuth vs OIDC: The Mental Model


If you remember only one thing from this article, remember this:


OAuth vs OIDC
OAuth vs OIDC

When Should You Use OAuth?


Use OAuth when your application needs delegated authorization.


Examples:

  • Accessing a user's calendar

  • Accessing a user's files

  • Calling protected APIs

  • Delegating permissions to third-party applications

  • Service-to-service authorization


The key requirement is:

"This application needs permission to access a protected resource."

When Should You Use OIDC?


Use OIDC when your application needs user authentication and identity.


Examples:

  • Login

  • Single Sign-On

  • Social login

  • Enterprise authentication

  • User identity federation


The key requirement is:

"This application needs to authenticate a user and know who they are."

Can You Use OAuth and OIDC Together?


Absolutely.


In fact, this is extremely common. A modern application might use OIDC to authenticate the user and OAuth access tokens to call protected APIs.


Quick Decision Guide


Ask yourself what problem you're solving.

  • "I need users to log in." Think: OIDC

  • "I need my application to access an API." Think: OAuth

  • "I need users to log in and then access protected APIs." Think: OIDC + OAuth

  • "I need a service to access another service without a user." Think: OAuth authorization, using an appropriate flow for the application architecture.

Recent Posts

See All
Important Security Update for Next.js 15 & 16

A critical vulnerability in React Server Components (CVE-2025-55182) has been responsibly disclosed. It affects React 19 and frameworks that use it, including Next.js (CVE-2025-66478). The issue is ra

 
 
bottom of page