OAuth 2.0
An industry-standard authorization framework that lets users grant third-party applications scoped access to their resources without sharing passwords
Table of Contents
Structure Diagram
What is OAuth 2.0?
An industry-standard authorization framework that lets users grant third-party applications scoped access to their resources without sharing passwords. It is a core concept in Auth & Security within Web Dev.
Core Principles
OAuth 2.0 is an authorization (delegated access) standard—not an authentication protocol by itself. Instead of handing your Google password to a third-party calendar app, you sign in directly with Google and grant scoped permission; the app receives a time-limited Access Token restricted to those scopes.
When apps also need to verify user identity ("Sign in with Google"), they layer OpenID Connect (OIDC) on top of OAuth 2.0 to receive a signed ID Token.
Practical Takeaways
- Always use Authorization Code + PKCE: The legacy Implicit Flow is deprecated because tokens leak in browser URLs and history. Use Authorization Code with PKCE (
code_challenge/code_verifier) across mobile, SPA, and server apps alike. - Validate the
stateparameter: Bind a cryptographicstatenonce to the user's session to prevent Login CSRF attacks during the OAuth callback. - Request least-privilege scopes: Ask only for the scopes needed upfront and use incremental authorization when additional permissions are required later.
Notable Examples
- Social SSO (Google, GitHub, Apple): Built on OAuth 2.0 + OIDC for passwordless federated sign-in.
- SaaS integrations (Slack apps, Zapier, Calendar sync): Granting scoped, revocable API access to external tools.