These protocols power "Log in with Google," enterprise SSO, and API authorization. Know what each does.
OAuth lets an app access resources on your behalf without getting your password.
You → "Let App X read my calendar"
→ Google issues App X an access token (scoped, time-limited)
→ App X uses the token to call the Calendar API
Key terms: resource owner (you), client (App X), authorization server (Google), access token, scope.
Use the Authorization Code flow with PKCE for web and mobile apps. Avoid the legacy Implicit flow.
OIDC is a thin authentication layer on top of OAuth 2.0. It adds an ID token (a JWT) proving who the user is. "Log in with Google/Apple" is OIDC.
The XML-based SSO standard common in enterprises. The Identity Provider (IdP) sends a signed SAML assertion to the Service Provider (SP). Functionally similar to OIDC, just older and XML-heavy.
A JWT is a compact, signed (not necessarily encrypted) token with three parts:
header.payload.signature
eyJhbG.. . eyJzdWI.. . SflKxw...
alg: none — reject unsigned tokens; pin the expected algorithm.exp; use refresh tokens.localStorage — exposes them to XSS; prefer HttpOnly cookies for browser sessions.| Need | Use |
|---|---|
| Third-party API access | OAuth 2.0 |
| Modern app login | OpenID Connect |
| Enterprise SSO (legacy) | SAML |
| Stateless service tokens | JWT (carefully) |