OAuth vs OIDC vs SAML: Which Should You Use?

Three dates explain most of the confusion around login protocols. SAML 2.0 became an OASIS standard on 15 March 2005. OAuth 2.0 arrived as RFC 6749 in October 2012. OpenID Connect reached its final 1.0 form in February 2014. SAML predates the first iPhone by more than two years, and it still runs enterprise single sign-on at companies around the world. A protocol from 2005, a framework from 2012, and an identity layer from 2014 now share the same login screen.

Teams treat the three as interchangeable options on a menu. That mix-up has a price. I have seen login flows built on the wrong protocol, access tokens used as proof of identity, and enterprise SSO projects that stalled for months because nobody asked which job each protocol does. The names sound alike, the redirect screens look alike, and the failure shows up late, in a security review or a customer integration that refuses to work.

This guide separates the three by job, by flow, and by the security rules that apply today. The comparison table in the middle gives you the short version. The scenarios near the end give you the answer for your stack. Read the definitions first, because the rest of the guide follows from them.

Each Protocol, Defined Plainly

OAuth 2.0 handles delegated authorization. RFC 6749 defines it as a framework that lets a third-party application obtain limited access to an HTTP service on behalf of a resource owner. A scheduling app reads your calendar without holding your password. A photo editor exports an image to your cloud drive with a scope that covers one folder and nothing else. OAuth answers one question: can this app do this thing, with this permission, for this user? It does not answer who the user is. That gap sits at the center of the confusion, and it causes more bad login designs than any other single misunderstanding in web auth.

OpenID Connect, shortened to OIDC, adds identity on top of OAuth 2.0. The specification opens with a single clear sentence: OpenID Connect 1.0 is a simple identity layer on top of the OAuth 2.0 protocol. OIDC adds an ID token, a signed JWT that carries claims about the authenticated user, plus a standard UserInfo endpoint for fetching profile data. The ID token states that an authorization server authenticated an end user, and it carries the claims that describe that user. OIDC turns an authorization framework into a login system. Sign in with Google, sign in with Microsoft, and sign in with Apple all run OIDC under the surface, with OAuth 2.0 moving the tokens underneath.

SAML 2.0 predates both. The OASIS standard, dated 15 March 2005, defines how an identity provider sends signed XML assertions to a service provider. A user signs in once at the identity provider, the provider posts a signed assertion through the browser, and the service provider opens a session based on that assertion. SAML grew up in enterprise IT, where one identity provider serves dozens of internal apps, and it still dominates that world. Okta describes SAML as mostly a web-based authentication mechanism because it relies on the browser to broker the flow, and that description matches how it behaves in practice.

Protocols prove identity. Factors prove the person at the keyboard is the account owner. Passkeys vs passwords change the factor, not the protocol, and a passkey login still needs OIDC or SAML to carry the result into the app. Authentication and authorization also split apart in other corners of the stack. Email has the same division of labor, and our email authentication setup guide walks through SPF, DKIM, and DMARC as three separate checks that each answer a different question. Keep the split in mind and the three protocols stop looking interchangeable.

How the Three Flows Differ in Practice

An OIDC login runs through a short sequence of redirects and token exchanges. The app sends the browser to the identity provider. The user signs in there. The provider returns an authorization code to the app. The app exchanges that code for an ID token and an access token, then verifies the ID token signature and reads the claims inside it. Public clients add PKCE, a code verifier that ties the first request to the token exchange, so a stolen authorization code alone buys an attacker nothing. The ID token carries the identity. The access token carries the permission to call an API. Two tokens, two jobs, one flow.

A SAML login moves a document instead of tokens. The service provider redirects the browser to the identity provider. The user signs in. The identity provider posts a signed XML assertion back through the browser, through HTTP POST binding, and the service provider validates the signature, reads the attributes in the assertion, and opens a session. No tokens travel to an API afterward, because SAML stops at the login. The assertion is the whole message, and the browser is the courier.

Raw OAuth 2.0 skips identity entirely. The app requests a token with a defined scope, receives it, and calls an API with it. Nothing in that exchange states who the user is in a form the app can trust as a login. An access token can carry a user identifier as a side effect, and some providers stuff one in, but the specification never promises it. Treating that identifier as a login credential means trusting a value that was built for API calls, issued for a different purpose, and revocable without any signal to the login session.

A laptop in a dark room showing lines of security code on screen, illustrating login and authentication protocols

Native apps follow a stricter rule. RFC 8252, published in October 2017, states that OAuth 2.0 authorization requests from native apps should only go through external user agents, primarily the system browser. Embedded web views hide the address bar, so a user cannot tell whether the login page belongs to the real identity provider or to a page that copied its design. The system browser keeps the address bar visible and keeps the app out of the password path. PKCE itself dates to RFC 7636, from September 2015, and it became mandatory for public clients in the current best practice, RFC 9700.

OAuth 2.0 vs OIDC vs SAML: The Comparison Table

Read the first row first. The primary job decides the rest: format, transport, and fit all follow from what the protocol was built to do.

AspectOAuth 2.0OpenID ConnectSAML 2.0
Primary jobDelegated authorization for APIsAuthentication and single sign-onEnterprise single sign-on
Data formatJSON tokens, often JWTJSON tokens, ID token as JWTSigned XML assertions
How it travelsRedirect plus back-channel token exchangeRedirect plus back-channel token exchangeBrowser POST of an XML assertion
First standardizedRFC 6749, October 2012Core 1.0 final, February 2014OASIS Standard, March 2005
Built forAPI access on behalf of a userLogin for web, mobile, and APIsBrowser SSO across enterprise apps
Mobile and SPA fitGood, with PKCEGood, with PKCEWeak, browser-only by design
Pick it whenAn app needs API access, not loginAnything new needs loginAn enterprise IdP or legacy app demands it

The table hides one asymmetry worth stating in plain words. OIDC contains OAuth 2.0. A team that picks OIDC gets OAuth 2.0 as part of the deal, with the ID token added on top. SAML stands apart, with its own format and its own transport, which is the reason migrations away from SAML take real work instead of a configuration change. The age column also tells a story: SAML predates modern mobile apps by years, and its browser-only shape shows that history in every integration.

Why Do Teams Still Confuse OAuth With Login?

The confusion has a simple cause. OAuth 2.0 shows up in almost every login flow, because OIDC builds on it, so teams see OAuth in the network trace and conclude that OAuth is the login. The trace shows the truth and hides it at the same time. The authorization code, the token exchange, and the access token all belong to OAuth 2.0. The ID token belongs to OIDC. Remove the ID token and the login disappears, while the API access keeps working. That test separates the two in one step: if removing a piece breaks login but leaves API calls intact, that piece is the identity layer.

The mistake compounds when a team copies a tutorial that calls the whole flow OAuth login. Tutorials shorten names, and the shortened name sticks. I treat any login design that mentions only OAuth as unfinished until OIDC or SAML shows up in the diagram. A design doc that names the identity layer, the token types, and the verification step for the ID token has done the work. A design doc that says login with OAuth has skipped it.

Okta frames the split in its own documentation: OAuth 2.0 controls and delegates authorization to access a protected resource, while OIDC extends OAuth 2.0 with user authentication and single sign-on functionality. Vendor framing, but accurate framing, and it matches the specifications. The OpenID Foundation overview states the same relationship from the standards side, calling OIDC an interoperable authentication protocol based on the OAuth 2.0 framework of specifications. Two sources, one answer, and the answer has stayed stable for a decade.

Security Rules You Cannot Skip

RFC 9700, published in January 2025 as BCP 240, rewrote the security baseline for OAuth 2.0, and it reads like a list of past mistakes. Clients should not use the implicit grant, the flow that returned access tokens in the authorization response, and should use the authorization code grant instead. Public clients must use PKCE. Refresh tokens for public clients must be sender-constrained or use refresh token rotation. Each rule answers a specific attack: tokens leaked from browser history, codes intercepted on the redirect, and refresh tokens replayed after theft. The rules look strict because the attacks they stop are cheap to run.

DPoP, defined in RFC 9449 from September 2023, gives teams the sender-constraining option. A DPoP-bound token carries a proof that ties it to a key the client holds, so a stolen token fails at the next API call. OAuth 2.1, the draft that folds these rules into a single specification, still sits at draft-ietf-oauth-v2-1-17, last updated on 30 October 2026. I checked the draft status while writing this guide, and it remains a draft, not an RFC, so cite it as a direction of travel, not as settled law. A newer best practice, RFC 10017, covers browser-based applications specifically, and it deserves a read before any SPA login design ships.

Four rules cover most of the risk in a new build. Use authorization code with PKCE for every public client, including SPAs and mobile apps. Keep tokens out of the URL fragment, where browser history and referrer headers can capture them. Rotate refresh tokens, or bind them to a sender key with DPoP. Send native app authorization through the system browser, never through an embedded web view. Credential hygiene around these flows matters as much as the flows themselves. Our MCP explained guide covers how AI coding tools handle credentials and context, and the same discipline applies to the tokens your login flow issues. Agent-initiated grants add a new attack surface, and our prompt injection explainer shows how a crafted instruction can steer an agent into requesting access it should not hold.

How to Choose: Five Scenarios, Five Answers

New web app login. Pick OIDC with authorization code and PKCE. The ID token proves identity, the access token calls your API, and the flow matches every current best practice document. No SAML needed, no custom session protocol to invent.

Mobile app login. Pick OIDC with PKCE through the system browser. RFC 8252 exists because embedded web views caused real phishing incidents, and the system browser rule removes the app from the password path entirely. Store the refresh token with rotation, and bind it with DPoP when your API supports it.

B2B enterprise SSO. Pick SAML when the customer identity provider demands it. Large enterprises standardized on SAML years ago, and their IT teams have runbooks, monitoring, and vendor support built around it. Offer OIDC alongside it when the customer identity provider supports both, because new integrations land faster on OIDC. The wrong choice here is not a technical failure. It is a stalled deal, with an integration that cannot start until the protocol matches.

Service-to-service API calls. Pick OAuth 2.0 client credentials and leave login out of it. Two services exchanging a token for API access need no user, no browser, and no identity layer. Adding OIDC here adds a redirect flow that no human will ever complete.

Legacy app with SAML only. Keep SAML at the edge or place an OIDC-to-SAML bridge in front of the app. The bridge lets new users sign in with OIDC while the legacy app keeps receiving the SAML assertions it expects. Rip-and-replace migrations of working SSO fail more often than bridges do, and the bridge buys time to retire the app on a schedule instead of under pressure.

Final Thoughts

The decision rule fits in one line. Login means OIDC, or SAML when the enterprise demands it. API access means OAuth 2.0. Raw OAuth 2.0 alone is not login, and no amount of careful token handling turns it into one. Three protocols, three jobs, and the mix-ups disappear once each job has a name.

Audit your current flows against the checklist in the security section. Look for the implicit grant, for public clients without PKCE, for refresh tokens that neither rotate nor bind to a sender key, and for native apps that authenticate inside an embedded web view. Each finding has a fix in the same section, and most fixes take hours, not weeks. Agent-driven access deserves the same audit, because agents now request tokens on your behalf. Our guide on AI agents vs workflows helps you decide where agents belong in your stack before you hand them credentials.

Share your stack in the comments: which identity provider you use, which flow you run, and whether SAML still shows up in your integrations. The answers vary more than the specifications suggest, and the variation teaches more than any single guide can.

Irfan is a Creative Tech Strategist and the founder of Grafisify. He spends his days testing the latest AI design tools and breaking down complex tech into actionable guides for creators. When he’s not writing, he’s experimenting with generative art or optimizing digital workflows.

Leave a Reply

Your email address will not be published. Required fields are marked *

You might also like
npm vs pnpm vs Yarn: Which Should You Use?

npm vs pnpm vs Yarn: Which Should You Use?

Passkeys vs Passwords: Which Is More Secure?

Passkeys vs Passwords: Which Is More Secure?

SPF, DKIM, and DMARC: A Practical Setup Guide

SPF, DKIM, and DMARC: A Practical Setup Guide

How to Build a Home Server with a Raspberry Pi

How to Build a Home Server with a Raspberry Pi

Nginx Reverse Proxy for Docker: Practical Setup Guide

Nginx Reverse Proxy for Docker: Practical Setup Guide

How to Speed Up a Slow WordPress Site

How to Speed Up a Slow WordPress Site