Passwords & identity

OAuth vs SAML: What Is the Difference, and Which Should You Use?

SAML proves who a user is for enterprise single sign-on. OAuth lets an app access a user's resources without their password. They solve different problems, and most organizations use both.

Cysoro Security TeamPublished · 9 min read
SAMLWho are you?XML assertionOAuthWhat can it do?Access tokenvsPASSWORDS & IDENTITYOAuthvs SAMLDifferent jobs. Often both.
Quick answer

SAML is an authentication protocol for enterprise single sign-on, using signed XML assertions between an identity provider and an application. OAuth 2.0 is an authorization framework that lets an application access a user's resources with a scoped token, without their password. OpenID Connect adds authentication on top of OAuth.

Key takeaways

  • SAML authenticates users, mainly for enterprise SSO; OAuth authorizes applications, mainly for API and third-party access.
  • SAML uses signed XML assertions over browser redirects; OAuth uses access tokens, often JSON, over API calls.
  • Most organizations use both, and OpenID Connect is the modern choice when you need login plus API access in one flow.

You log into a work app with your company account, then you let a calendar app read your meetings without giving it your password. Both feel like single sign-on, but they use different protocols — and mixing them up is how teams pick the wrong tool for the job.

What is the difference between OAuth and SAML?

SAML authenticates users, mainly for enterprise single sign-on, while OAuth authorizes applications to access resources on a user's behalf. SAML answers "who is this person?", OAuth answers "what is this app allowed to do for them?"

SAML, or Security Assertion Markup Language, is an open standard for authentication in enterprise environments. It lets you log in once to your company's identity provider and gain access to apps such as Google Workspace or Salesforce without entering another password.

OAuth 2.0, or Open Authorization, is a framework for delegated authorization. It lets an app request limited access to a user's resources — files, email, calendars — on another system, without needing the user's password. The user approves a specific scope, and the app gets a token for that scope only.

Because they solve different problems, they are not interchangeable. Cisco Duo's comparison puts it the same way: SAML authenticates users and dominates enterprise SSO, while OAuth authorizes access to APIs. A team that needs enterprise SSO picks SAML; a team that needs an app to call an API on a user's behalf picks OAuth. Many teams need both.

What is SAML?

SAML is an enterprise single sign-on protocol that exchanges authentication and authorization data between an identity provider (IdP) and a service provider (SP), using signed XML assertions. It is browser-based and remains the most widely deployed protocol for enterprise SSO.

The IdP is the system that knows who the user is — your company directory, Okta, Entra ID or Google Workspace. The SP is the application the user wants to open. When the user tries to open the app, the app redirects them to the IdP, the IdP authenticates them, and it sends back a signed assertion saying who they are.

SAML assertions can also carry attributes and roles, such as department or job title, so the application can make authorization decisions from them. That does not make SAML a full authorization framework — it does not replace role-based access control inside the application.

SAML is strongest where it was designed to work: enterprise web applications, regulated environments, and organizations that already run a central identity provider. Its XML format is verbose, and it is less natural for mobile apps and APIs, which is where OAuth fits better.

What is OAuth 2.0?

OAuth 2.0 is an open delegation standard for granting secure access to resources without sharing user credentials. It lets a client, usually a third-party application, request permission from a resource owner, usually a user, to access a protected resource on their behalf.

The flow involves four parties: the user, the application, the authorization server, and the resource server that holds the user's data. The application asks the authorization server for permission, the user consents to a specific scope, and the authorization server issues an access token the application presents to the resource server.

The key point is that the application never sees the user's password. The token is limited in scope and time, and the user or the provider can revoke it without changing the password. That is why "log in with Google" for a third-party app and "let this app read my calendar" are OAuth, not password sharing.

OAuth does not directly support user authentication. It authorizes a client, and it authenticates that client with a client ID and secret, but it does not prove who the end user is. OpenID Connect was built on OAuth 2.0 to add that piece.

What is OpenID Connect, and where does it fit?

OpenID Connect, or OIDC, is an identity layer built on top of OAuth 2.0 that adds user authentication. It extends the OAuth authorization code flow with an ID token — a JSON Web Token that proves who the user is — so a single flow can verify identity and grant API access.

For modern web and mobile apps, OIDC is usually the right default. Okta's guide notes that modern identity architectures frequently combine all three protocols. It is API-friendly, uses JSON rather than XML, and works well for consumer sign-in, mobile apps and cloud-native services. SAML remains the right choice for legacy enterprise apps that only support SAML, and for organizations whose identity setup is built around it.

Most organizations end up using more than one protocol, and that is normal. The choice depends on the application: SAML for legacy enterprise apps, OAuth for API access, OIDC for modern and mobile sign-in. Your identity provider typically supports all three, so you choose per application rather than per company.

You can inspect the tokens OIDC uses with our free JWT decoder — paste an ID token to see its claims, issuer and expiry, without sending it anywhere.

OAuth vs SAML vs OIDC at a glance

This table is the comparison most teams actually need, with OIDC included because it is the third protocol in almost every real decision.

FeatureSAML 2.0OAuth 2.0OpenID Connect
Primary purposeAuthentication, enterprise SSOAuthorization, delegated accessAuthentication and authorization
Token formatXML assertion, digitally signedAccess token, often opaqueID token, JSON Web Token
TransportHTTP redirect or POST, browser-basedHTTP and REST, API-friendlyHTTP and REST, API-friendly
Common use caseEnterprise SSO across web appsAPI authorization between servicesConsumer and mobile sign-in
Best forLegacy and regulated enterprise appsThird-party apps, APIs, machine accessModern web and mobile apps
Proves user identity?YesNo, by itselfYes

How does SAML authentication work?

SAML authentication follows a short, browser-based exchange between the user, the identity provider and the application. Knowing the steps helps you diagnose the common failures, such as clock skew and certificate expiry.

SAML single sign-on in five steps1Open the appuser requestsa protected page2Redirectapp sends userto the IdP3Log inIdP checks theuser, plus MFA4Assertionsigned XML sayswho the user is5Accessapp trusts theassertionThe application never sees the user's password.
The SAML SSO flow: redirect, login, signed assertion, access. Illustration by Cysoro.
  1. The user opens an application that requires login.
  2. The application redirects the user to the identity provider with a SAML request.
  3. The identity provider authenticates the user, usually with a password and MFA.
  4. The identity provider sends a signed SAML assertion back to the application, usually by browser POST.
  5. The application verifies the signature, reads the user's identity and attributes, and grants access.

Two details cause most SAML failures. First, the assertion is time-sensitive, so a clock that is minutes off on either side can make it look expired. Second, the assertion is signed with a certificate, so an expired or rotated signing certificate breaks login until the application is updated with the new one.

How does OAuth 2.0 authorization work?

OAuth authorization follows a different shape: the user grants a scoped permission, and the application receives a token it can use for a limited time. The user is involved once, at consent, and the application then acts on its own.

  1. The application asks the authorization server for access to a specific scope, such as reading a calendar.
  2. The authorization server asks the user to log in and approve that scope.
  3. The authorization server issues an authorization code, which the application exchanges for an access token.
  4. The application presents the access token to the resource server to read or change the resource.
  5. When the token expires, the application uses a refresh token, if granted, to get a new one without asking the user again.

The authorization code flow with PKCE — proof key for code exchange — is the recommended flow for web and mobile apps, because it protects the code exchange even if the code is intercepted. The older implicit flow, which returned tokens directly in the browser URL, is now discouraged.

Scopes are the control that matters most. A token that can only read a calendar is far less dangerous than one that can read email, delete files and change settings. Ask for the narrowest scope that works, and treat a request for broad scopes as a reason to pause.

Which should you use: SAML, OAuth or OIDC?

Choose by what the application needs, not by which protocol sounds newer. The decision tree below covers the common cases.

  • Enterprise SSO to existing web apps: SAML, if the app supports it. It is the established standard, and your identity provider already speaks it.
  • Modern web or mobile sign-in: OIDC. It handles login and API access in one flow, with JSON tokens your developers already understand.
  • Third-party app access to user data: OAuth 2.0. Let the app access a calendar or files with a scoped token, never with the user's password.
  • Machine-to-machine API access: OAuth 2.0 client credentials flow, with a client ID and secret scoped to that service.
  • Regulated or legacy environment: SAML, often alongside OIDC for newer apps. Do not force a SAML-only app onto OAuth.

If an application supports both SAML and OIDC, prefer OIDC for new integrations — it is simpler to implement, easier to debug, and better suited to mobile and API use. Keep SAML for the applications that only offer it.

What are the common security mistakes with OAuth and SAML?

Both protocols are secure when implemented well and dangerous when misconfigured. The mistakes below appear in real breaches again and again.

  • Long-lived, broad tokens. A token that never expires and can do everything is a password by another name. Use short lifetimes, narrow scopes and rotation.
  • Skipping signature validation. A SAML assertion or ID token that is not verified is just a claim anyone can write. Always validate the signature, issuer, audience and expiry.
  • Storing tokens in the wrong place. Access tokens in local storage are exposed to cross-site scripting; refresh tokens need stronger protection. Follow your framework's guidance, and never log tokens.
  • Accepting any redirect URI. An OAuth client that accepts arbitrary redirect URIs lets an attacker steal authorization codes. Register exact redirect URIs and check them strictly.
  • Ignoring certificate rotation. SAML signing certificates expire. Track their expiry dates, or SSO breaks without warning — the same failure mode as a TLS error on iPhone when a certificate lapses.

On the human side, the same advice applies as everywhere else in identity: use a password manager, turn on phishing-resistant MFA where you can, and check whether a password has appeared in a breach with our pwned password checker.

Choose by the job, not the nameNeed enterprise SSO to existing web apps?Use SAMLNeed an app to access user data without a password?Use OAuth 2.0Need modern login plus API access in one flow?Use OIDCMost organizations use all three — one per application.
A simple decision guide for SAML, OAuth and OpenID Connect. Illustration by Cysoro.

Can OAuth and SAML work together?

Yes, and they often do. A common pattern is SAML for employee sign-in to the identity provider, and OAuth and OIDC for the applications and APIs behind it. In a Microsoft environment, for example, SAML can handle authentication while OAuth handles authorization, with both running at the same time.

Another common pattern is federation: one identity provider authenticates the user with SAML, then issues OAuth tokens for API access. The user logs in once, and the tokens they need for different systems are issued from that single login.

The practical lesson is to stop treating this as a choice between two rivals. SAML and OAuth are complementary tools, and the question to ask for each application is which one it supports and which job it needs done.

The bottom line

SAML proves who a user is for enterprise single sign-on. OAuth lets an app do a limited job on a user's behalf without their password. OpenID Connect combines the two for modern apps.

Pick SAML for legacy enterprise SSO, OAuth for API and third-party access, and OIDC for new web and mobile sign-in — and use a strong password generator and phishing-resistant MFA alongside whichever protocol you choose.

Frequently asked questions

What is the difference between OAuth and SAML?

SAML is an authentication protocol that proves who a user is, mainly for enterprise single sign-on. OAuth is an authorization framework that lets an application access a user's resources with a limited token, without their password. They solve different problems.

Can OAuth replace SAML?

Not directly. OAuth handles authorization, not user authentication. OpenID Connect, built on OAuth 2.0, adds authentication, so it can replace SAML for modern web and mobile sign-in, but many enterprise apps still require SAML.

What is OpenID Connect?

OpenID Connect, or OIDC, is an identity layer built on top of OAuth 2.0. It adds an ID token that proves who the user is, so one flow can handle both login and API access. It is the standard choice for modern web and mobile apps.

Is SAML more secure than OAuth?

Neither is inherently more secure. Security depends on implementation: signed assertions and short-lived tokens in SAML, and scoped tokens, PKCE and token rotation in OAuth. Both fail badly when misconfigured, for example when tokens are long-lived or overly broad.

Do I need both SAML and OAuth?

Many organizations do. SAML covers enterprise SSO to older or regulated applications, while OAuth and OIDC cover modern apps, mobile sign-in and API access. Your identity provider usually supports all three at once.

What is a SAML assertion?

A SAML assertion is a signed XML document from an identity provider that states who the user is, when they authenticated, and what attributes or roles they have. The application trusts the assertion because it is digitally signed by the identity provider.

What is an OAuth access token?

An access token is a credential an application presents to a resource server to prove it has permission to act on a user's behalf, for a specific scope and a limited time. It does not contain the user's password, and it can be revoked without changing that password.

Sources

  1. Cisco Duo — SAML vs OAuth vs OIDC: Key differences explained
  2. Okta — SAML vs OAuth: Comparison and Differences
  3. Stytch — SAML vs OAuth: Key Differences Explained
  4. Netwrix — SAML vs OAuth: Key Differences and Top Use Cases
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against Cisco Duo, Okta and Stytch comparisons of SAML, OAuth 2.0 and OpenID Connect, and the OAuth 2.0 and SAML specifications as summarized in those guides.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free