Let an app use your account safely, without ever giving it your password.
OAuth 2.0 lets an app use your account at another service, with limited permission, without ever seeing your password.
Old way: an app asks, “Give me your email and password for that service.” That is dangerous. The app could do anything, and you could only stop it by changing your password. OAuth fixes this with a delegated pass.
| Grant | Used for | Status |
|---|---|---|
| Authorization code + PKCE | Web apps, mobile apps and single-page apps with a user | The recommended one for user logins |
| Client credentials | Service to service, no user involved | Good and common |
| Refresh token | Get a new access token without asking the user again | Common companion |
| Device code | TVs and devices with no keyboard: type a code on your phone | Good for that case |
| Implicit | Old single-page apps: token comes straight back in the URL | Discouraged. Use code + PKCE |
| Resource owner password | App collects your password and sends it to the server | Discouraged. It defeats the purpose of OAuth |
| Term | Meaning in easy words |
|---|---|
| Access token | A short-lived pass used to call an API |
| Refresh token | A long-lived pass used only to get new access tokens |
| Scope | A named permission, like photos.read |
| Client | The app asking for access |
| Redirect URI | The exact address the user is sent back to after consent |
| Authorization code | A one-time code swapped for tokens |
| PKCE | Extra proof that the app that started the flow also finishes it |
| state | A random value that stops cross-site request forgery in the flow |
| Consent screen | The page where the user approves the permissions |
| OIDC | OpenID Connect: login on top of OAuth |
| ID token | A JWT from OIDC that says who the user is |
| Choice | We gain | We lose |
|---|---|---|
| Run your own auth server | Full control | You must keep it secure and running |
| Use a hosted identity provider | Less work, proven security | Cost and a dependency |
| Broad scopes | Fewer consent screens | More damage if a token leaks |
| Long refresh tokens | Fewer logins | Bigger risk if stolen |