SAML vs OAuth 2.0 vs OIDC: A Practical Deep Dive with Architecture & API Access Flows

Fayaz KhanFayaz Khan
4 min read

๐Ÿง  Core Concepts

ProtocolPurposeTypeFormatToken FormatIdeal Use Case
SAMLAuthentication onlyFederated AuthenticationXML-basedSAML Assertion (XML)Web SSO
OAuth 2.0Authorization onlyDelegated AuthorizationJSONAccess / Refresh TokensAPI Access
OIDCAuthentication + AuthorizationIdentity Layer on OAuth 2.0JSONID + Access TokensLogin + API Access

๐Ÿ“Œ High-level comparison of SAML vs OAuth 2.0 vs OIDC


๐Ÿ” SAML (Security Assertion Markup Language)

  • XML-based legacy protocol for Single Sign-On (SSO)

  • Common in enterprise apps

  • Provides a one-time SAML assertion during login

  • Does not support modern API access directly


๐Ÿ”“ OAuth 2.0

  • Delegated access model (Authorization)

  • Scopes define what can be accessed

  • Access Token & Refresh Token issued

  • Does not provide identity by itself


๐Ÿ”— OIDC (OpenID Connect)

  • Identity layer on top of OAuth 2.0

  • Adds ID Token to represent the user

  • Supports web, mobile, and APIs

  • Modern alternative to SAML

๐Ÿ“ŒOAuth + OIDC flow


๐Ÿงพ Use Case: Cross-App API Access

Scenario

  • You have App A (browser app) authenticated via SSO

  • App A needs to access App B and App C APIs

  • User should not re-login for App B/C data


๐ŸŽฏ Implementation Options

โœ… Option 1: SAML-Based (Legacy)

  • App A authenticates via SAML SSO

  • App B and C require separate API access

  • No native token support โ†’ need OAuth bridge

  • โŒ Not seamless for API access

  • App A uses OIDC to authenticate

  • Access Token allows API calls to App B/C

  • All via standard JWT tokens

  • โœ… Seamless and secure

โœ… Option 3: Hybrid Model

  • Use SAML for login

  • Issue OAuth tokens via token exchange

  • Requires extra setup (like Azure AD or custom IdP logic)


๐Ÿ’ก What is an Identity Provider (IdP)?

A system that:

  • Authenticates the user

  • Issues tokens (SAML Assertion / ID Token / Access Token)

Popular IdPs:

  • Azure AD

  • Okta

  • Auth0

  • Google Identity

๐Ÿ“ŒIdP role in auth ecosystem


๐Ÿ” Azure Active Directory (Azure AD)

  • Supports both SAML and OAuth/OIDC

  • Central user and app management

  • App registration enables:

    • Token issuance

    • Scopes and claims

    • SSO across applications

Example: App A calls App B API using token from Azure AD


๐Ÿ“Š Comparison Summary

FeatureSAMLOAuth 2.0OIDC
Auth or AuthZAuthenticationAuthorizationAuth + Authorization
FormatXMLJSONJSON
API AccessโŒโœ…โœ…
ID TokenโŒโŒโœ…
Browser Friendlyโœ…With OIDCโœ…
Best ForLegacy SSOAPI AccessWeb + API Unified Login

๐Ÿ”„ Token Flow with OIDC

  1. App A โ†’ Redirect to IdP (Azure AD)

  2. IdP authenticates โ†’ returns ID Token + Access Token

  3. App A uses Access Token to call App Bโ€™s API

  4. App B validates token and responds with data

๐Ÿ“Œ OIDC Token flow for browser + API


โœ… Recommendation

For modern apps needing login + API access:

  • Use OIDC over OAuth 2.0

  • Register all apps in a central IdP (like Azure AD)

  • Use access tokens for cross-app API communication


๐Ÿ“ Final Words

SAML has served enterprise SSO for years, but it falls short in a modern API-first world.

OAuth 2.0 + OIDC provides:

  • Lightweight tokens

  • Secure access control

  • Seamless experience across apps and APIs

Migrate if possible, and embrace the token-driven future.


๐Ÿ“ข Feedback or Questions?

Drop a comment or message :


0
Subscribe to my newsletter

Read articles from Fayaz Khan directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Fayaz Khan
Fayaz Khan

Hi, Iโ€™m Fayaz Khan โ€” a PLM Solution Architect with deep hands-on experience in 3DEXPERIENCE, real-world integrations, and enterprise system behavior. I work at the intersection of engineering, security, and systems thinking, navigating between PLM platforms, cloud infrastructure, APIs, and practical business needs. I prefer digging into why something works (or breaks), rather than just how to configure it. My writing is an attempt to document the often-overlooked details โ€” the silent bugs, the edge cases, the security gaps โ€” and sometimes, the mental models that help me make sense of it all.