OAuth vs OIDC: What's the Difference Between OAuth 2.0 and OpenID Connect?
OAuth vs OIDC: OAuth 2.0 grants an app access to data (authorization), while OpenID Connect adds login (authentication) with an ID token. What each is for.
OAuth 2.0 is for authorization: it lets an app get an access token to call an API on a user's behalf. OpenID Connect (OIDC) is for authentication: it's a thin layer on top of OAuth 2.0 that also gives the app an ID token, a signed statement of who the user is. If you want to read someone's Google Calendar, you need OAuth. If you want a "Sign in with Google" button, you need OIDC (which uses OAuth underneath).
The two are easy to confuse because they use the same redirects, the same endpoints and often the same libraries. The difference is what the app gets back and what it's allowed to conclude from it.
The short version
| OAuth 2.0 | OpenID Connect | |
|---|---|---|
| Answers | "May this app access this data?" | "Who is this user?" |
| Main output | Access token | ID token (plus an access token) |
| Token is meant for | The API (resource server) | Your app (the client) |
| Token format | Not defined by the spec; often opaque, sometimes a JWT | Always a JWT |
| How you ask for it | Scopes like calendar.readonly |
Include the openid scope |
| Typical use | "Connect your Google Drive" | "Sign in with Google" |
If authentication vs authorization is still fuzzy, read that first; everything below follows from it.
What OAuth 2.0 does
OAuth solves delegated access. Your app wants to read a user's calendar. Instead of asking for their Google password, it sends them to Google, they approve "This app wants to see your calendar," and Google gives your app an access token. Your app sends that token to the Calendar API, which checks it and returns data.
What matters here is who the access token is for. It's addressed to the API, not to your app. Your app is a courier: it carries the token to the API and doesn't need to understand what's inside. The OAuth spec deliberately doesn't say what an access token looks like. It might be a random string that only the issuer can look up.
What OAuth doesn't do is tell your app who the user is. An access token says "the bearer may read this calendar." It doesn't say "this is alice@example.com, she logged in two minutes ago, and this token was issued to your app." (What is OAuth? covers the full flow.)
What OpenID Connect adds
People wanted to use OAuth for login anyway, and everyone built it slightly differently. OIDC standardised it. It adds three main things.
1. The ID token
When your app includes the openid scope in the request (the OIDC Core spec says requests "MUST contain the openid scope value"), the provider returns an ID token alongside the access token. The ID token is always a JWT, signed by the provider, and it's addressed to your app. The required claims are:
iss: who issued it, e.g.https://accounts.google.comsub: a stable, unique identifier for the user at that issueraud: who it's for. It must contain your app's client IDexp: when it expiresiat: when it was issued
With the email and profile scopes you also get claims like email, email_verified and name. If you sent a nonce in the request, the ID token carries it back, which protects against replayed tokens.
A decoded ID token payload looks something like:
{
"iss": "https://accounts.google.com",
"sub": "110169484474386276334",
"aud": "1234567890-abc.apps.googleusercontent.com",
"exp": 1795000000,
"iat": 1794996400,
"email": "alice@example.com",
"email_verified": true,
"nonce": "n-0S6_WzA2Mj"
}
2. The UserInfo endpoint
OIDC defines a standard UserInfo endpoint. Your app calls it with the access token and gets profile claims back. It's useful when you need more than the ID token carries. The spec requires that the sub from UserInfo matches the sub in the ID token, so you know both describe the same user.
3. Discovery
An OIDC provider publishes a JSON document at /.well-known/openid-configuration listing its endpoints, supported scopes and the URL of its signing keys (jwks_uri). Google's is at https://accounts.google.com/.well-known/openid-configuration. Libraries read it so you don't hard-code URLs, and they use the keys to verify ID token signatures (JWKS and key rotation).
Example: "Sign in with Google"
Here's what happens when a user clicks the button on your site:
- Your app redirects to Google with
scope=openid email profile, your client ID, a redirect URI, astatevalue, anonce, and a PKCE challenge. - The user signs in to Google and approves.
- Google redirects back with a one-time authorization code.
- Your server exchanges the code (plus the PKCE verifier) at Google's token endpoint and gets an ID token and an access token.
- Your server validates the ID token and reads
subandemail. - You look up or create the user by
sub, and start your own session.
Steps 1 to 4 are plain OAuth (the authorization code flow, ideally with PKCE). Steps 5 and 6 are what OIDC adds. If you also asked for a Drive scope, you'd keep the access token and use it to call the Drive API. If you only wanted login, you might never use the access token at all.
For the setup side (client IDs, redirect URIs, why it breaks when you leave localhost), see Sign in with Google explained.
Validating the ID token
"Validate" has a specific meaning in the spec. At minimum:
- Verify the signature with the provider's published keys.
- Check that
issexactly matches the provider you expect. - Check that
audcontains your client ID. - Check that
expis in the future. - If you sent a
nonce, check it matches.
Use a library rather than writing this yourself. In Node with jose:
import { createRemoteJWKSet, jwtVerify } from "jose";
const googleKeys = createRemoteJWKSet(
new URL("https://www.googleapis.com/oauth2/v3/certs")
);
const { payload } = await jwtVerify(idToken, googleKeys, {
issuer: ["https://accounts.google.com", "accounts.google.com"],
audience: process.env.GOOGLE_CLIENT_ID,
});
// payload.sub is the stable user ID; also compare payload.nonce
// with the nonce you stored for this login.
Google lists both issuer forms in its documentation, which is why the example accepts either. Use sub as the user's key, not email. Email addresses can change, and sub is guaranteed stable and unique per provider.
The common mistake: using an access token as proof of identity
The bug looks like this. A mobile app or SPA does an OAuth flow, gets an access token, and sends it to your backend. Your backend calls the provider's profile API with it, gets back an email, and logs that user in.
The problem is that the access token wasn't issued to your app. Any app the user has ever granted access to holds a similar token. A malicious app the user once connected to can take the token it received, send it to your backend, and your backend will happily log it in as that user. Nothing in that check confirms the token was meant for you.
An ID token prevents this because of the aud claim: it names the client it was issued to, and you reject anything that doesn't name yours. That's the core reason OIDC exists.
The rules:
- To know who the user is, validate an ID token with
audset to your client ID. - To call an API, use an access token, and treat it as opaque in your app.
- Don't send ID tokens to APIs as if they were access tokens. They're addressed to your app, not the API.
Some providers don't speak OIDC for user login. GitHub's OAuth apps, for example, give you only an access token, and you call GitHub's user API with it. That's fine when your own server ran the flow end to end, received the token directly from GitHub's token endpoint, and used it immediately. What you shouldn't do is accept such a token from a client and trust it.
Which one do you need?
- Users log in to your app with an outside account: OIDC.
- Your app reads or writes a user's data in another service: OAuth.
- Both: one flow with
openidplus the API scopes. You get both tokens. - Your own users, your own passwords: neither, unless you want single sign-on across several apps.
If you use an auth service such as Clerk, Auth0 or Supabase Auth, it does the OIDC part for you; you'll still see these terms in its settings.
EasySpawn gives every environment its own HTTPS URL, which you need as the redirect URI when you test a login flow outside localhost. See how it works or join the waitlist.
Related: Authentication vs Authorization: What's the Difference? · What Is OAuth? "Sign in With Google" and Delegated Access Explained · What Is a JWT? JSON Web Tokens Explained Simply · JWKS and Signing Key Rotation for JWTs
Keep reading
What Is SSO (Single Sign-On)? How It Works and When Your App Needs It
Single sign-on lets people log in once with one company account — Google Workspace, Microsoft Entra, Okta — and get into many apps without separate passwords. How SSO works, SAML vs OpenID Connect, why business customers demand it, and how to add it to your own app.
What Is OAuth? "Sign in With Google" and Delegated Access Explained
OAuth is the standard that lets one app access your data in another app without ever seeing your password — it's behind "Sign in with Google" and "Connect your GitHub account". How the OAuth flow works step by step, what scopes and tokens are, OAuth vs OpenID Connect, and the mistakes to avoid.