Protocols
OAuth, OpenID Connect and SAML compared
One is for authorization, two are for sign-in, and most organizations run all three. When to use which, and how they fit together.
OAuth 2.0, OpenID Connect and SAML 2.0 are often listed as alternatives. Only two of them are. OAuth is for authorization: letting a client call an API. OpenID Connect and SAML are both for federated authentication: letting an application sign a user in on the strength of an identity provider's login. Most organizations run all three at once, usually through the same identity provider.
Each in one line
- OAuth 2.0
- A framework for issuing access tokens that let a client call an API on a user's (or its own) behalf. RFC 6749 (2012), secured by RFC 9700 (2025). See OAuth 2.0.
- OpenID Connect
- An identity layer on OAuth: the client also receives a signed ID token saying who signed in, when and how. OpenID Foundation, Core 1.0 (2014, errata set 2 in 2023). See OpenID Connect.
- SAML 2.0
- An XML-based standard in which an identity provider sends a signed assertion through the browser to a service provider. OASIS (2005, with approved errata). See SAML 2.0.
Side by side
| OAuth 2.0 | OpenID Connect | SAML 2.0 | |
|---|---|---|---|
| Purpose | Delegated authorization to APIs | Authentication (sign-in) plus basic profile; also OAuth authorization | Authentication (web SSO) and attribute exchange |
| Main artifact | Access token (format unspecified; often opaque or an RFC 9068 JWT); refresh token | ID token (signed JWT) plus OAuth tokens | Assertion (XML) inside a Response |
| Audience of the artifact | The API (resource server) | ID token: the client (aud = client_id) | The SP (AudienceRestriction) |
| Transport | Browser redirect for the code; JSON over HTTPS back channel for tokens; Authorization header to APIs | Same as OAuth | Browser redirect (DEFLATE + base64 in the URL) and auto-submitted HTML form POST (base64); optional back-channel artifact resolution |
| Signing | Not required by RFC 6749; RFC 9068 JWT access tokens MUST be signed | ID tokens MUST be signed (JWS); optional JWE encryption | XML Signature (enveloped); with POST, every assertion must be covered by a signature on it or on the response |
| Key and metadata discovery | RFC 8414 /.well-known/oauth-authorization-server, jwks_uri | OIDC Discovery /.well-known/openid-configuration, jwks_uri | SAML metadata XML (entity ID, endpoints, certificates), exchanged out of band or fetched |
| User identifier | None defined (RFC 9068 sub for JWT access tokens) | iss + sub | IdP entity ID + NameID (e.g. persistent) |
| Native mobile and SPA fit | Good: code flow with PKCE, system browser (RFC 8252) | Good: same flows | Poor: designed around browser form posts to a server-side SP; no standard API tokens |
| API access | Yes, that is its job | Yes, via the OAuth access token | Not directly; an SP typically exchanges the login for its own session or tokens |
| Logout | Not defined; tokens can be revoked (RFC 7009) | Separate specs: RP-Initiated, Front-Channel and Back-Channel Logout 1.0 (listed in OIDC Core §15.7) | Single Logout profile (Profiles §4.4) |
| Main pitfalls | Using it for login; loose redirect URIs; bearer token leakage | Skipping ID token validation; keying users on email | Signature wrapping; missing Audience/Recipient/InResponseTo checks; IdP-initiated replay |
Logout deserves a caution in all three: each application has its own session, and "single" logout only works if every participant implements it and the messages actually reach them. Treat it as best effort, and keep application sessions reasonably short.
When to use which
- A new web, mobile or single-page application needs users to sign in: OpenID Connect with the authorization code flow and PKCE. It works natively in mobile apps and SPAs, uses JSON and JWTs that every platform handles, and gives you an access token for your own API from the same flow.
- An application needs to call an API on a user's behalf, or a service needs to call another service: OAuth 2.0 (authorization code + PKCE for users, client credentials for services). Add OpenID Connect only if the client also needs to know who the user is.
- A SaaS product or enterprise application only offers SAML: use SAML for it. It is mature, well supported by enterprise identity providers, and there is no security reason to avoid it if the SP validates correctly.
- You are building a product that enterprises will connect to their IdP: support OpenID Connect, and SAML as well if your customers ask for it; many enterprise IdPs are configured around SAML.
- A device with no browser: the OAuth device authorization grant, with OIDC scopes if you need identity.
How they coexist in federation
In practice the identity provider is the hub. The user signs in once at the IdP, with whatever authentication strength its policy requires, and the IdP issues whichever artifact each application understands: a SAML assertion for the SaaS app, an ID token for the new web app, an access token for the API that web app calls. The protocols differ, but the authentication event behind them is the same, so policy decisions (MFA, device posture, session length) belong at the IdP, not in each protocol.
Some patterns that follow:
- Protocol translation. An IdP or federation proxy can accept SAML from an upstream partner IdP and issue OIDC to internal apps, or the reverse. NIST SP 800-63C-4 calls such components federation proxies ("sometimes referred to as brokers"). It notes that they can translate between federation protocols, that all subscriber information flows through them (so an attacker who compromises the proxy gets subscriber attributes and activity without targeting the IdP or RP), and that the FAL seen by the downstream RP is the lowest FAL along the whole path, which the proxy SHALL represent accurately (§3.3.3).
- Same assurance rules for both assertion formats. SP 800-63C-4 treats the OIDC ID token and the SAML assertion as examples of the same thing, an assertion, and applies the same federation assurance levels to both. At every FAL the RP SHALL validate the assertion, the IdP SHALL sign it, and it SHALL be audience-restricted with replay protection. At FAL2 the assertion is restricted to a single RP and the transaction SHALL be initiated by the RP, which rules out IdP-initiated SAML at that level.
- Account keys. Whatever the protocol, key federated accounts on the issuer plus its stable subject identifier: (
iss,sub) in OIDC, (IdP entity ID, persistentNameID) in SAML. Never on email alone. - Tokens do not cross protocols by themselves. A SAML assertion is not an OAuth access token, and an ID token is not either. If an API must trust a login that happened via SAML, the IdP or a token service issues a proper access token for that API.
Federation assurance at a glance
From NIST SP 800-63C-4 Table 1, which applies equally to OIDC and SAML:
| Requirement | FAL1 | FAL2 | FAL3 |
|---|---|---|---|
| Audience restriction | Multiple RPs allowed per assertion; single RP recommended | Single RP per assertion | Single RP per assertion |
| Replay protection | Required per RP | Required | Required |
| Assertion injection protection | Recommended | Required; transaction begins at the RP | Required; transaction begins at the RP |
| Trust agreement | Subscriber-driven or pre-established | Pre-established | Pre-established |
| Presentation | Bearer assertion | Bearer assertion | Holder-of-key assertion or bound authenticator |
See assurance levels for how FAL relates to AAL and IAL.
Practical guidance
- Default to OpenID Connect for new sign-in integrations and OAuth for API access; keep SAML for applications that need it.
- Run all three from one identity provider so authentication policy is enforced in one place.
- Prefer SP- or RP-initiated flows; they are required at FAL2 and above.
- Validate artifacts fully: ID token validation, SAML response validation, access token validation.
- Key accounts on issuer plus stable subject, never on email.
- Do not use ID tokens or SAML assertions as API credentials; issue access tokens.
- Inventory every federated application and its protocol, and review it alongside your access reviews.
Sources
- RFC 6749: The OAuth 2.0 Authorization Framework, IETF. IETF Trust Legal Provisions (brief quotations with attribution).
- OpenID Connect Core 1.0 incorporating errata set 2, OpenID Foundation. OpenID Foundation specification (cited, brief quotations).
- Profiles for the OASIS Security Assertion Markup Language (SAML) V2.0, OASIS. OASIS specification (cited, brief quotations).
- NIST SP 800-63C-4: Digital Identity Guidelines, Federation and Assertions, NIST. Public domain (U.S. government work).
- RFC 9700: Best Current Practice for OAuth 2.0 Security, IETF. IETF Trust Legal Provisions (brief quotations with attribution).
- SAML V2.0 Errata 05, OASIS. OASIS specification (cited, brief quotations).