Link to Introduction: Why Protocol Choice MattersIntroduction: Why Protocol Choice Matters
In modern application architectures—especially where identity, security, and directory systems converge—the distinction between authentication and authorization protocols is crucial. Developers and architects integrating user login or securing APIs must confidently choose the right protocol, or risk exposing their applications to serious security and identity failures.
A frequent and dangerous mistake is treating OAuth 2.0 as an authentication protocol, using it for user login. For example, incorrectly accepting an OAuth 2.0 access token as proof that a user is who they claim to be can result in impersonation attacks. Understanding how OAuth 2.0 and OpenID Connect (OIDC) differ, and when to use each, is essential for secure, standards-based implementations.
Link to The Basics: OAuth 2.0 Authorization FrameworkThe Basics: OAuth 2.0 Authorization Framework
OAuth 2.0, defined in RFC 6749, is an authorization framework. Its purpose is to allow a client application to obtain limited, delegated access to protected HTTP resources (such as APIs) on behalf of a resource owner (typically an end-user), via an access token. It enables permission grants without sharing user credentials, using flows such as the authorization code and client credentials.
Key OAuth 2.0 properties:
- Standardizes how clients obtain and use access tokens for resource access.
- Focuses solely on authorization—granting access to resources, not proving user identity.
- The access token is a bearer token; possessing it is sufficient to access the delegated API.
- Does not provide authenticated user identity or guarantee who the token was issued to.
Example:
A third-party app requests permission via OAuth 2.0 to access a user's calendar API. If the user consents, the app receives an access token, which it presents to the API to perform actions in the user's context.
OAuth 2.0 never issues an assertion of user identity; the access token is designed for resource (API) access only. Using it to infer authentication is unsupported and insecure.
Link to OpenID Connect: Adding an Identity LayerOpenID Connect: Adding an Identity Layer
OpenID Connect (OIDC) extends OAuth 2.0 by adding an identity layer that standardizes authentication. OIDC enables secure user login, single sign-on (SSO), and federated identity use cases by issuing an ID token—a signed JWT containing claims about the authentication and user.
How OIDC builds on OAuth 2.0:
- Uses standard OAuth 2.0 flows but requires the
openidscope to indicate an authentication request. - Responds with both an access token (for API access) and an ID token (for identity and login).
- The ID token contains verifiable claims about the user and authentication event, intended for the Relying Party (the client).
- Adds endpoints for discovery, user info, and dynamic configuration.
Example:
A cloud-based SaaS app uses OIDC to allow users to sign in with their corporate directory. The app redirects users to the identity provider, which authenticates them and returns an ID token. The app validates the ID token’s signature and claims to establish the user's identity.
OIDC solves for standardized, secure authentication and SSO—all built on the established OAuth 2.0 authorization base.
Link to Technical Comparison: Tokens and FlowsTechnical Comparison: Tokens and Flows
Link to Access Tokens (OAuth 2.0)Access Tokens (OAuth 2.0)
- Purpose: Grant access to protected APIs/resources.
- Audience: Resource servers (APIs).
- Contents: Scopes and permissions; usually opaque to clients.
- Not proof of user identity.
Link to ID Tokens (OIDC)ID Tokens (OIDC)
- Purpose: Assert authenticated user identity.
- Audience: Relying Party (client).
- Contents: Claims about authentication (e.g., issuer, subject, audience, expiry).
- Delivered as a signed JWT; must be validated for signature, issuer, audience, expiration, and nonce.
Link to Protocol Flows and ScopesProtocol Flows and Scopes
Both OAuth 2.0 and OIDC use similar flows (like Authorization Code). OIDC requires the openid scope—without it, only OAuth 2.0 flows and access tokens are issued, and authentication is not assured. Additional standard scopes (profile, email) are available in OIDC to allow access to user info endpoints.
Endpoint discovery is fully standardized in OIDC (/.well-known/openid-configuration) and covered for OAuth 2.0 via RFC 8414. This metadata enables secure configuration and protocol interoperability.
Example difference:
- OAuth 2.0 Authorization Code Flow (no
openidscope): Issues only an access token. - OIDC Authorization Code Flow (with
openidscope): Issues both an access token and an ID token, enabling secure login.
Link to Security, Threats, and Best PracticesSecurity, Threats, and Best Practices
Link to Risks of MisapplicationRisks of Misapplication
Using OAuth 2.0 alone for authentication—such as accepting an access token as proof of login—exposes applications to impersonation, session fixation, and unauthorized access. Access tokens are bearer tokens, and their possession does not guarantee authenticated user identity.
OIDC mandates strict validation of ID tokens:
- Signature verification: Confirms the token is from the trusted issuer.
- Claim validation: Ensures the token is intended for this client (
audclaim), by this issuer (iss), and is not expired or replayed. - Nonce: Protects against token replay.
RFC 9700 and OAuth 2.1 (draft) emphasize not using OAuth 2.0 alone for authentication, and recommend standard OIDC implementations for user login scenarios.
Example attack:
If an application uses an OAuth 2.0 access token for login, an attacker could trick it by presenting a valid access token intended for another API, leading to impersonation.
Link to Protocol Decision Table: When to Use EachProtocol Decision Table: When to Use Each
| Feature / Scenario | OAuth 2.0 | OpenID Connect (OIDC) |
|---|---|---|
| Protocol type | Authorization framework | Authentication layer on OAuth |
| API/resource access | Yes | Yes |
| Secure user authentication (login, SSO) | No | Yes |
| Token for APIs | Access Token | Access Token |
| Token for identity | Not supported | ID Token (JWT) |
| User info / claims discovery | Custom / not standardized | Standardized endpoints |
| Federated identity/SSO | No | Yes |
| Required scope for auth | Custom | openid |
| Auth endpoint discovery | Optional via RFC 8414 | Mandatory (.well-known) |
Link to Use Case Decision GuideUse Case Decision Guide
- User login, SSO, federated identity: Use OIDC. Authenticate users and verify identity using ID tokens and OIDC-compliant providers.
- API/resource access with delegated permissions: Use OAuth 2.0 (or OIDC if login is also needed). Issue and verify access tokens; user identity is out of scope.
- Combining both (common in modern applications): Use OIDC; handle authentication with ID tokens, and use access tokens for API authorization.
- Enterprise/legacy SSO (SAML): OIDC is modern and preferred for browser and mobile SSO, but SAML remains in use for some enterprise scenarios.
Scenario Examples:
- Login to cloud portal: Use OIDC for authentication, validate ID tokens, and optionally request user info.
- Delegate API access to 3rd-party app: Use OAuth 2.0 for authorization; issue access tokens only, no authentication.
Link to Conclusion: Key Lessons and Next StepsConclusion: Key Lessons and Next Steps
The principal difference is this: OAuth 2.0 enables delegated authorization, not authentication; OpenID Connect adds the necessary identity and authentication layer to enable secure user login, SSO, and federated identity. Misapplying OAuth 2.0 for authentication is a serious design flaw with real security consequences.
For any application requiring user login or federated identity, always choose OpenID Connect (with the openid scope and proper ID token validation). Reserve OAuth 2.0 for scenarios where you strictly need delegated API access without trusting any authentication-related properties.
Developers should consult the authoritative standards for implementation detail and best practices:
- RFC 6749 (OAuth 2.0 framework)
- RFC 9700 (OAuth 2.0 security best practices)
- RFC 8414 (protocol metadata and discovery)
- OAuth 2.1 draft (future baseline and updated guidance)
Correct protocol selection and rigorous validation are your strongest tools for building secure, future-proof identity architectures.