OAuth 2.0 & OIDC
Secure authorization without sharing passwords-the foundation of "Sign in with Google."
1The Valet Key Analogy
OAuth 2.0 is an authorization framework for granting limited access. OIDC (OpenID Connect) adds authentication on top-it tells you who the user is.
2Key Players
Resource Owner
The user who owns the data (you)
You want to let an app access your Google Calendar
Client
The app requesting access
A scheduling app like Calendly
Authorization Server
Issues tokens after user consent
accounts.google.com
Resource Server
Hosts the protected data
Google Calendar API
3Authorization Code Flow
The most secure flow for web apps with a backend:
4OAuth vs OIDC
OAuth 2.0
Purpose: Authorization
Provides: Access token
Answers: What can this app do?
Access user's photos, post on their behalf
OIDC
Purpose: Authentication + Authorization
Provides: ID token + Access token
Answers: Who is this user?
Get user's email, name, profile picture
OIDC adds an ID token (JWT) containing user info. Without OIDC, OAuth only grants access-you don't know WHO granted it.
5Token Types
Access Token
15 min - 1 hourAuthorize API calls. Sent in Authorization header.
Short-lived. If leaked, damage is limited.
Refresh Token
Days to monthsGet new access tokens without user login.
Store securely. Can be revoked.
ID Token (OIDC)
VariesContains user identity (sub, email, name).
JWT format. Verify signature before trusting.
6Common Scopes
| Scope | Access Granted |
|---|---|
| openid | Basic OIDC. Required for ID token. |
| profile | User's name, picture, etc. |
| User's email address | |
| offline_access | Refresh token for long-term access |
| calendar.read | Read user's calendar (provider-specific) |
7Key Takeaways
?Quiz
1. 'Sign in with Google' to get user's email uses:
2. Access token leaked. Why is damage limited?