SAML vs OAuth vs OpenID Connect: Which Do You Need?
Understand the differences between SAML 2.0, OAuth 2.0, and OpenID Connect. Learn when to use each protocol and how they work together for authentication and authorization.
If you're building or integrating enterprise applications, you've almost certainly encountered three acronyms: SAML, OAuth, and OpenID Connect. They all deal with identity and access, but they solve different problems in fundamentally different ways. Choosing the wrong protocol—or misunderstanding what each one does—can lead to security gaps, poor user experiences, and costly rearchitecting down the road. This guide breaks down each protocol, explains when to use it, and shows how they can work together.
What Is SAML 2.0?
Security Assertion Markup Language (SAML) 2.0 is an XML-based open standard for exchanging authentication and authorization data between an Identity Provider (IdP) and a Service Provider (SP). Ratified in 2005, SAML was one of the first widely-adopted protocols for federated single sign-on (SSO) in enterprise environments.
SAML works by having the Identity Provider generate a signed XML document called an “assertion” that contains information about who the user is and what attributes they have. The Service Provider validates this assertion and grants access accordingly. The entire exchange happens through the user's browser via HTTP redirects and POST requests.
How a SAML SSO Flow Works
- A user navigates to your application (the Service Provider).
- Your application generates a SAML AuthnRequest and redirects the user's browser to the Identity Provider.
- The Identity Provider authenticates the user (via password, MFA, or an existing session).
- The Identity Provider creates a signed SAML assertion containing the user's identity and attributes.
- The user's browser POSTs the assertion back to your application's Assertion Consumer Service (ACS) endpoint.
- Your application validates the assertion's signature, extracts user information, and creates a local session.
Key Characteristics of SAML
- XML-based: Assertions are verbose XML documents, which makes them heavier than JSON-based alternatives but also well-suited to environments with strict schema validation requirements.
- Browser-centric: SAML relies on browser redirects, making it a natural fit for web applications but a poor fit for mobile apps, SPAs that call APIs directly, or IoT devices.
- Mature ecosystem: Nearly every enterprise Identity Provider (Okta, Azure AD, Ping Identity, OneLogin, AD FS) supports SAML. It remains the dominant protocol for workforce SSO.
- Authentication-focused: SAML's primary purpose is to tell a Service Provider “this user is who they say they are.”
What Is OAuth 2.0?
OAuth 2.0 is an authorization framework—not an authentication protocol. Published as RFC 6749 in 2012, OAuth was designed to solve a specific problem: allowing a third-party application to access a user's resources on another service without the user sharing their password.
The classic example is a photo printing service that needs access to your Google Photos. Instead of giving the printing service your Google password, OAuth lets you grant limited, scoped access. Google issues an access token to the printing service, and that token only allows it to read your photos—nothing else.
How an OAuth 2.0 Authorization Code Flow Works
- Your application redirects the user to the authorization server with a request for specific scopes (e.g., “read photos”).
- The user authenticates with the authorization server and consents to the requested scopes.
- The authorization server redirects back to your application with an authorization code.
- Your application exchanges the authorization code for an access token (and optionally a refresh token) via a back-channel server-to-server call.
- Your application uses the access token to call the resource server's API on behalf of the user.
Key Characteristics of OAuth 2.0
- Authorization, not authentication: OAuth answers “what is this application allowed to do?” not “who is this user?” An access token grants permissions but does not inherently carry identity information.
- Token-based: Access tokens are typically short-lived and scoped. Refresh tokens allow applications to obtain new access tokens without re-prompting the user.
- Flexible grant types: OAuth 2.0 defines multiple flows (authorization code, client credentials, device code) to support different application types including web apps, mobile apps, CLIs, and server-to-server integrations.
- JSON and HTTP-native: Unlike SAML's XML, OAuth uses JSON payloads and standard HTTP, making it lightweight and well-suited for APIs and modern applications.
Common misconception: Many developers use OAuth 2.0 alone for user login. This is problematic because an access token does not guarantee the user's identity to your application—it only proves that someone authorized access to a resource. This gap is exactly what OpenID Connect was created to fill.
What Is OpenID Connect (OIDC)?
OpenID Connect (OIDC) is an identity layer built on top of OAuth 2.0. Finalized in 2014, it adds a standardized way to verify a user's identity and retrieve basic profile information. If OAuth 2.0 is “I'm allowed to access this resource,” then OIDC adds “and here's proof of who I am.”
The key addition is the ID token—a JSON Web Token (JWT) that contains claims about the authenticated user, such as their unique identifier, email address, and when they last authenticated. This token is signed by the Identity Provider and can be verified by the client application.
How an OIDC Flow Works
- Your application redirects the user to the OpenID Provider with an authorization request that includes the
openidscope. - The user authenticates and consents.
- The OpenID Provider redirects back with an authorization code.
- Your application exchanges the code for an ID token, an access token, and optionally a refresh token.
- Your application validates the ID token's signature and claims to confirm the user's identity.
- Optionally, your application calls the UserInfo endpoint with the access token to retrieve additional profile claims.
Key Characteristics of OIDC
- Authentication on top of authorization: OIDC inherits all of OAuth 2.0's capabilities and adds a proper identity layer with the ID token.
- JWT-based ID tokens: ID tokens are compact, JSON-based, and can be validated without a network call by verifying the signature against the provider's public keys.
- Discovery and dynamic registration: OIDC defines a
.well-known/openid-configurationendpoint, allowing clients to automatically discover the provider's endpoints, supported scopes, and signing keys. - Standard scopes and claims: OIDC standardizes scopes like
profile,email, andaddress, ensuring consistent profile information across providers. - Modern and API-friendly: Like OAuth, OIDC uses JSON and HTTP, making it an excellent choice for SPAs, mobile apps, and microservices architectures.
Key Differences at a Glance
| Aspect | SAML 2.0 | OAuth 2.0 | OpenID Connect |
|---|---|---|---|
| Primary Purpose | Authentication (SSO) | Authorization (delegated access) | Authentication + Authorization |
| Data Format | XML | JSON | JSON / JWT |
| Token Type | XML Assertion | Access Token + Refresh Token | ID Token (JWT) + Access Token |
| Transport | Browser redirects (HTTP POST/Redirect) | HTTP + back-channel | HTTP + back-channel |
| Best For | Enterprise workforce SSO | API access, third-party integrations | User login for modern apps |
| Mobile / SPA Support | Poor | Excellent | Excellent |
| Complexity | High (XML parsing, certificate management) | Moderate | Moderate |
| Year Standardized | 2005 | 2012 | 2014 |
When to Use Each Protocol
Use SAML When...
- You need enterprise SSO: Your customers are large organizations with existing Identity Providers like Okta, Azure AD, or AD FS that already speak SAML. Workforce SSO remains SAML's strongest use case.
- You're integrating with legacy systems: Many established SaaS applications and on-premise systems only support SAML. If your integration partner requires it, you need to support it.
- Your application is a traditional web app: Server-rendered applications that handle authentication entirely on the server side work naturally with SAML's browser-based redirect flow.
- Regulatory or contractual requirements mandate it: Some industries and government contracts specifically require SAML-based federation.
Use OAuth 2.0 When...
- You need API authorization: Your application needs to access APIs on behalf of a user, such as reading a user's calendar, sending emails, or accessing files in a cloud storage provider.
- You're building a platform with third-party integrations: If other developers need to build apps that access your users' data, OAuth provides a secure delegation model without exposing user credentials.
- You need machine-to-machine (M2M) authentication: The client credentials grant allows services to authenticate with each other without user involvement, which is essential for microservices architectures.
- You need fine-grained, scoped permissions: OAuth's scope model lets you grant specific, limited permissions rather than all-or-nothing access.
Use OpenID Connect When...
- You need user login for a modern application: If you're building a SPA, mobile app, or any application that needs to know who the user is, OIDC is the modern standard.
- You want both authentication and API access: Because OIDC is built on OAuth, a single flow gives you both an ID token (identity) and an access token (API authorization).
- You're implementing “Sign in with” social login: Google, Apple, Microsoft, and most social providers implement OIDC. It's the standard behind the “Sign in with Google” button.
- You need a lightweight, developer-friendly protocol: OIDC's JSON-based tokens, discovery endpoints, and extensive library support make it faster to implement than SAML.
How These Protocols Work Together
A common misconception is that you must choose one protocol and use it exclusively. In reality, many production systems use multiple protocols simultaneously, each handling the scenario it was designed for.
Enterprise SSO + API Access
Consider a B2B SaaS application. Your enterprise customers want their employees to log in using their company's Identity Provider via SAML SSO. At the same time, your application has a REST API that your customers' internal tools need to call. In this architecture:
- SAML handles employee login through the corporate IdP.
- After SAML authentication, your backend issues OAuth 2.0 access tokens for API calls.
- Internal tools use the OAuth client credentials grant for automated, server-to-server API access.
Social Login + Enterprise SSO
A platform that serves both individual users and organizations might use:
- OIDC for individual users signing in with Google, Apple, or Microsoft accounts.
- SAML for enterprise customers whose IT departments require federation with their corporate IdP.
- OAuth 2.0 for the underlying API authorization layer, regardless of how the user authenticated.
The key insight is that SAML and OIDC both answer the authentication question (“who is this user?”), while OAuth provides the authorization layer (“what are they allowed to do?”). Your authentication gateway normalizes the identity regardless of which protocol was used upstream, and then OAuth tokens govern API access downstream.
A Decision Framework for Choosing the Right Protocol
Use this framework to determine which protocols you need. Start with these questions:
1. Who Are Your Users?
- Enterprise employees logging in through a corporate Identity Provider: You need SAML support. Most enterprise IT departments expect it.
- Consumers or individual users signing in with email/password or social accounts: Use OIDC.
- Both enterprise and consumer users: Support both SAML and OIDC, with a unified session layer underneath.
2. What Kind of Application Are You Building?
- Traditional server-rendered web app: SAML or OIDC both work. Choose based on your user base.
- Single-page application (SPA) or mobile app: Use OIDC with PKCE (Proof Key for Code Exchange). SAML is poorly suited for these architectures.
- API or microservice: Use OAuth 2.0 access tokens for authorization between services.
- Platform with third-party developer ecosystem: You need a full OAuth 2.0 authorization server so third parties can request scoped access.
3. What Do You Need to Know About the User?
- Just that they are authorized to access a resource: OAuth 2.0 alone is sufficient.
- Who they are (identity) and their profile data: Use OIDC for its standardized ID tokens and UserInfo endpoint.
- Identity assertions with custom enterprise attributes: SAML supports rich attribute statements that can carry group memberships, roles, department, and other organizational data.
4. What Are Your Integration Requirements?
- Integrating with established enterprise software: Expect to need SAML.
- Integrating with modern cloud services and social providers: Most support OIDC.
- Building APIs that other services consume: Use OAuth 2.0.
Security Considerations for Each Protocol
Each protocol has its own security profile and potential pitfalls to watch for:
SAML Security
- XML signature wrapping attacks: Improper validation of XML signatures can allow attackers to forge assertions. Always use a well-maintained SAML library rather than building your own XML validation.
- Certificate management: SAML relies on X.509 certificates for signing. Expired or compromised certificates break SSO or create security holes. Automate certificate rotation.
- Replay attacks: Always validate assertion timestamps and enforce the
NotBeforeandNotOnOrAfterconditions.
OAuth 2.0 Security
- Always use PKCE: The authorization code flow with PKCE (RFC 7636) prevents authorization code interception attacks. This is mandatory for public clients (SPAs, mobile apps) and recommended for all clients.
- Token storage: Access tokens must be stored securely. Use HTTP-only cookies for web apps and secure storage APIs for mobile apps. Never store tokens in localStorage.
- Scope validation: Always validate that the scopes in an access token match what your API endpoint requires. Do not rely on the token's existence alone.
OIDC Security
- Validate the ID token fully: Check the signature, issuer (
iss), audience (aud), expiration (exp), and nonce. Skipping any of these checks opens the door to token forgery or replay attacks. - Use the nonce parameter: The nonce prevents replay attacks by binding the ID token to a specific authentication request.
- Verify at_hash: When the ID token is delivered alongside an access token, verify the
at_hashclaim to ensure the access token hasn't been substituted.
How TitaniumVault Supports All Three Protocols
TitaniumVault was built from the ground up to support modern, multi-protocol authentication architectures. Rather than forcing you to choose a single protocol, TitaniumVault provides a unified identity platform that speaks SAML, OAuth 2.0, and OpenID Connect natively.
SAML SSO for Enterprise Customers
TitaniumVault acts as both a SAML Identity Provider and a SAML Service Provider. When your enterprise customers need to federate their corporate IdP with your application, TitaniumVault handles the entire SAML handshake—parsing assertions, validating signatures, mapping attributes to user profiles, and managing certificates. You get enterprise-grade SSO without building XML parsing or certificate rotation logic into your application.
OAuth 2.0 for API Authorization
TitaniumVault includes a full OAuth 2.0 authorization server that supports the authorization code grant (with PKCE), client credentials grant, and refresh token rotation. Define custom scopes that map to your application's permissions, and TitaniumVault will issue properly-scoped access tokens that your APIs can validate. Machine-to-machine integrations get dedicated client credentials, keeping automated workflows secure and auditable.
OpenID Connect for Modern Login
TitaniumVault is a fully compliant OpenID Connect Provider. Your SPAs, mobile apps, and server-side applications can use standard OIDC libraries to authenticate users, retrieve ID tokens with verified identity claims, and access the UserInfo endpoint for profile data. The discovery endpoint at .well-known/openid-configuration means OIDC-compatible clients can auto-configure themselves.
One Platform, All Protocols
The real power is in unification. A user who authenticates via SAML SSO gets the same session, the same role-based access control, and the same audit trail as a user who authenticates via OIDC. Your application receives a consistent identity regardless of the upstream protocol. This means you write your authorization logic once and it works for every authentication method.
- Unified user directory: All users live in one place, whether they authenticated via SAML, OIDC, or direct credentials.
- Consistent RBAC: Roles and permissions apply uniformly across all authentication methods.
- Complete audit logging: Every authentication event, token issuance, and authorization decision is logged regardless of which protocol was used.
- Strong MFA enforcement: TitaniumVault enforces TOTP and WebAuthn-based MFA across all login flows, including SAML and OIDC.
Conclusion
SAML, OAuth 2.0, and OpenID Connect are not competing protocols—they are complementary tools designed for different scenarios. SAML remains the standard for enterprise workforce SSO. OAuth 2.0 is the foundation for secure, scoped API authorization. OpenID Connect adds the identity layer that modern applications need on top of OAuth's authorization framework.
Most production applications that serve both enterprise and consumer users will eventually need all three. The question is not “which one should I use?” but rather “which ones do I need right now, and how do I architect my system so adding the others later is straightforward?”
The simplest answer is to use an identity platform that handles all three from day one. That way, you can start with OIDC for your initial user login, add SAML when your first enterprise customer asks for SSO, and use OAuth tokens for API authorization throughout—all without rearchitecting your authentication layer.
Ready to implement multi-protocol authentication without the complexity? Try TitaniumVault free for 14 days or view our pricing.