OAuth 2.0 is an authorization framework, standardized as RFC 6749, that lets a third-party app obtain limited access to your resources on another service without handling your password. You log in directly with the service, approve specific permissions called scopes, and the app receives a short-lived access token it can use for only those permissions.
Key takeaways
- OAuth is authorization, not authentication: it controls what an app may do, not who you are.
- Use the authorization code flow with PKCE for every user-facing app, and never use the implicit or password grants in new work.
- Access tokens are short-lived and scoped, so review connected apps regularly and revoke anything you no longer use.
You have seen the button a hundred times: "Sign in with Google" or "Connect your calendar". Behind it sits OAuth, the framework that lets apps work together without passing your password around. When it works well, you barely notice it. When it is built badly, one careless approval can hand an app far more access than you meant to give.
What is OAuth?
OAuth 2.0 is an authorization framework, standardized as RFC 6749 in 2012, that lets a third-party app obtain limited access to your resources on another service without handling your password. You approve specific permissions, and the app receives a token that works only for those permissions.
The problem it solves is old. Before OAuth, an app that wanted your photos, calendar or contacts usually asked for your username and password, stored them, and logged in as you. That gave the app full access, and if the app was breached, your password leaked with it.
OAuth replaces that with delegation: you log in directly with the service, the service asks whether the app may do a defined set of things, and the app gets a token instead of your credentials.
OAuth is the industry-standard protocol for authorization, as OAuth.net explains, and it is used by Google, Microsoft, GitHub, Facebook and almost every large API provider. It focuses on developer simplicity while covering web apps, desktop apps, mobile phones and devices with no keyboard.
Is OAuth authentication or authorization?
OAuth is authorization, not authentication. It answers what an app may do on your behalf, never who is holding it. If you need proof of identity, that job belongs to OpenID Connect, which is built on top of OAuth.
The distinction matters in practice. A bare access token proves that somebody authorized an app, but it does not tell the app who you are. Developers who treat an access token as a login proof create a classic security hole: an attacker who obtains a token for one service can sometimes present it as identity to another.
OpenID Connect fixes this by adding an ID token, a signed statement from the identity provider that names the user.
So when you click "Sign in with Google", you are usually using both: OAuth 2.0 to authorize the app, and OpenID Connect to prove your identity. When you click "Connect your calendar" in a scheduling app, that is usually OAuth alone, because the app only needs access, not a login.
Who are the four roles in OAuth?
Every OAuth flow involves four roles: the resource owner, the client, the authorization server and the resource server. The resource owner is usually you, the client is the app asking for access, and the two servers belong to the service holding your data.
| Role | Who it is | Example |
|---|---|---|
| Resource owner | The person who can grant access | You, the Google account holder |
| Client | The app requesting access | A calendar scheduling app |
| Authorization server | Issues tokens after login and consent | Google's authorization server |
| Resource server | Holds the protected data and checks tokens | Google Calendar API |
The authorization server and the resource server may be the same server or separate ones. In many setups they are run by the same provider, but the roles stay distinct: one decides whether to issue a token, the other decides whether a token is good enough to return data.
Clients also come in two types. A confidential client, such as a server-side web app, can safely store a client secret. A public client, such as a mobile app or a single-page app, cannot, because anything shipped in the app can be extracted. That difference decides which flow and which protections the app must use.
How does OAuth work?
OAuth works by redirecting you to the service, letting you log in and approve specific permissions there, and then giving the app a short-lived code it exchanges for tokens. Your password never passes through the app.
Walk through the most common flow, the authorization code flow, with a concrete example. You want a scheduling app to read your calendar, so you click "Connect Google Calendar". The app sends your browser to Google with its client ID, the permissions it wants, a redirect address, a random state value and a PKCE challenge.
Google shows you a login page and a consent screen: "This app wants to read your calendar events." You approve. Google redirects you back to the app with a short-lived authorization code. The app's server then exchanges that code, plus its client secret and the PKCE proof, for an access token and usually a refresh token. From then on, the app calls the calendar API with the access token in an authorization header.
Google describes the same sequence in its code model guide: the user requests a code, Google sends it to a callback or redirect endpoint, and the backend exchanges the code for access and refresh tokens. The code itself is single-use and short-lived, typically valid for about ten minutes.
What are the OAuth grant types?
OAuth defines several grant types, which are the different ways an app can obtain a token. The authorization code grant is the one to use for user-facing apps, the client credentials grant is for server-to-server work, and the device code grant is for devices with no keyboard.
| Grant type | Use it for | Status in 2026 |
|---|---|---|
| Authorization code + PKCE | Web, mobile and single-page apps acting for a user | Recommended for all new work |
| Client credentials | Server-to-server calls with no user involved | Recommended for machine-to-machine |
| Device code | TVs, printers and consoles with no keyboard | Recommended for those devices |
| Refresh token | Getting a new access token without another login | Recommended, with rotation where supported |
| Implicit | Old browser apps that returned tokens in the URL | Deprecated, do not use |
| Password | Apps that collected your password directly | Deprecated, do not use |
The implicit flow returned the access token directly in the URL fragment, where it could leak into browser history, logs and referrer headers. The password grant asked the app to collect your password, which defeated the whole point of OAuth. The OAuth 2.0 Security Best Current Practice, RFC 9700, formally deprecates both, and OAuth 2.1 drops them entirely.
For server-to-server work, the client credentials grant is the right choice: the app authenticates with its own client ID and secret and receives a token for its own resources, with no user in the loop. For a smart TV, the device code grant shows a code on screen and asks you to approve it on your phone, which is far safer than typing a password on a remote control.
What are access tokens, refresh tokens and scopes?
An access token is a short-lived credential an app presents to an API. A refresh token is a longer-lived credential used to obtain new access tokens. A scope is a permission string that limits what a token may do, such as reading a calendar but not sending email.
Access tokens are usually bearer tokens: whoever holds one can use it, so the system relies on them being short-lived, sent only over HTTPS, and scoped as narrowly as possible. Many providers issue access tokens that last about an hour.
When one expires, the app uses its refresh token to get another without bothering you. Refresh tokens last much longer, sometimes weeks or months, which is why they must live on the server, never in browser storage. They should also be rotated: each use issues a new refresh token and invalidates the old one, so a stolen copy stops working quickly.
Scopes are where your judgment matters most. A consent screen that asks for "read your calendar" is very different from one that asks for "read and send email, manage contacts and access Drive". Read the scopes before you approve.
If an app asks for far more than its job needs, that is a reason to pause, not a detail to skip. You can inspect a JWT access token with our free JWT decoder to see what it actually claims.
Tokens can also be revoked. If an app is compromised or you simply stop using it, revoking its tokens cuts off access immediately, without changing your password. That is one of OAuth's biggest advantages over password sharing: access is per app, so removing one app does not break the others.
What is PKCE and why does it matter?
PKCE is an extension that protects the authorization code exchange from interception. The app creates a random code verifier, sends only a hash of it at the start, and must present the original verifier when exchanging the code for a token.
Without PKCE, an attacker who intercepted the authorization code in the redirect could exchange it for a token, because the code alone was enough. With PKCE, the intercepted code is useless without the verifier, which never travels in the redirect.
That is why current guidance says to always combine the authorization code flow with PKCE, even for confidential clients that also use a client secret. The OAuth.net guidance on the authorization code grant states this directly: always combine it with PKCE, even for confidential clients.
PKCE also helps public clients that have no secret at all. A mobile app cannot keep a client secret, because anyone can extract it from the app package. PKCE gives it a per-request secret instead, generated fresh for every login, which is far harder to steal in advance.
OAuth vs OpenID Connect vs SAML: what is the difference?
OAuth grants delegated access, OpenID Connect adds identity on top of OAuth, and SAML is an older enterprise single sign-on protocol. They solve overlapping but different problems, and many systems use more than one.
| OAuth 2.0 | OpenID Connect | SAML 2.0 | |
|---|---|---|---|
| Main job | Delegated API access | Login and identity proof | Enterprise single sign-on |
| What it proves | An app may act for you | Who you are | Who you are, to an app |
| Token format | Access and refresh tokens | ID token (JWT) plus OAuth tokens | Signed XML assertions |
| Typical use | Connect a third-party app | Sign in with Google or Microsoft | Corporate apps via an identity provider |
If you are building a consumer app that needs to call Google or Microsoft APIs, use OAuth 2.0 with OpenID Connect. If you are wiring up enterprise single sign-on for internal apps, SAML is still common, though many identity providers now offer OpenID Connect as the simpler option. Our guide to spear phishing explains why fake login pages are so effective, which is exactly the attack OAuth consent screens must be designed to resist.
What are the risks of OAuth, and how do you stay safe?
The main OAuth risks are over-broad scopes, malicious consent screens, token theft and open redirect flaws. The defenses are reading scopes, checking the domain of every consent page, keeping tokens short-lived and off the browser, and revoking apps you no longer use.
For users, the single most important habit is reading the consent screen. Attackers run fake apps with names close to real ones, and they ask for broad scopes such as full mailbox access. A real consent page lives on the provider's own domain, such as accounts.google.com, never on a look-alike domain.
If the page asks you to type your password into the app itself rather than redirecting you to the provider, close it: that is not OAuth, it is credential harvesting.
For developers, the checklist is longer. Use the authorization code flow with PKCE for every user-facing app. Validate the state value to stop cross-site request forgery. Compare redirect URIs by exact string match, and register every allowed URI in advance.
Store tokens server-side, never in local storage. Rotate refresh tokens. Follow the OAuth 2.0 Security Best Current Practice, RFC 9700, which OAuth.net summarizes as mandating PKCE, exact redirect matching and no implicit or password grants.
Also remember that OAuth does not remove the need for strong account security. Turn on phishing-resistant multi-factor authentication on the accounts that authorize apps, use a password manager and unique passwords, and check your connected apps at least every few months. A strong password on an account that has authorized a malicious app is no protection at all.
How do you review and revoke OAuth access?
Review connected apps in the account settings of each service you use, and revoke anything unfamiliar or unused. Google, Microsoft and GitHub each have a third-party access page that lists every app, its scopes and when it last used them.
Do this on a schedule, not only after a scare. Set a calendar reminder every three months. Remove apps from services you no longer use, apps you tried once and forgot, and any app whose scopes look broader than its job. If you find an app you do not recognize, revoke it first and investigate second: revoking is safe and reversible, while leaving a malicious app connected is not.
If you suspect an app misused its access, revoke it, change your account password, review recent account activity for unfamiliar logins or sent messages, and report the app to the provider. For work accounts, tell your IT team as well, because a compromised connected app can reach shared drives and mailboxes, not just your own data. Our small business cybersecurity checklist includes connected-app review as a routine control.
The bottom line
OAuth 2.0 is the reason apps can work together without sharing your password. It delegates limited, revocable access through tokens, and it works well when builders follow current best practice: authorization code flow with PKCE, exact redirect matching, short-lived tokens and narrow scopes.
Your part is simple: read consent screens, approve only the scopes an app needs, and revoke apps you no longer use. Do that, and OAuth stays what it was designed to be, a safer way to connect your apps. You can check the tokens your own apps use with the free JWT decoder.
Frequently asked questions
What is OAuth in simple terms?
OAuth is a way to let one app use your data on another service without giving it your password. You log in with the service itself, approve exactly what the app may do, and the app gets a limited, revocable token instead of your credentials.
Is OAuth the same as logging in with Google?
Not quite. Signing in with Google uses OpenID Connect, which is built on top of OAuth 2.0 and adds an ID token that proves who you are. OAuth alone only grants access to resources; it does not prove your identity.
What is the difference between OAuth and SAML?
OAuth is mainly for delegated API access, letting apps act on your behalf with scoped tokens. SAML is mainly for enterprise single sign-on, letting you sign in once and access many apps with signed assertions.
What is an access token in OAuth?
An access token is a short-lived credential an app presents to an API to prove it has permission to act on your behalf. It is usually a bearer token, which means anyone holding it can use it, so it should be short-lived, scoped narrowly and sent only over HTTPS.
What is a refresh token?
A refresh token is a longer-lived credential an app uses to get a new access token when the old one expires, without asking you to log in again. It must be stored securely on the server, and it can be revoked to cut off access.
Is OAuth 2.0 safe?
OAuth 2.0 is safe when implemented to current best practice: authorization code flow with PKCE, exact redirect URI matching, short-lived tokens and a state value to stop cross-site attacks. Most OAuth breaches come from skipped steps, not from the protocol itself.
What is PKCE in OAuth?
PKCE, pronounced pixy, is an extension that protects the authorization code exchange. The app creates a secret code verifier, sends only its hash at the start, and proves it knows the original when exchanging the code for a token.
How do I revoke an app's OAuth access?
Open the account settings of the service that holds your data, find the connected apps or third-party access page, and remove the app. That revokes its tokens. Do this for any app you no longer use.
Sources
The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.
Checked against RFC 6749 via OAuth.net, the OAuth 2.0 Security Best Current Practice (RFC 9700), and Google Identity documentation.
How we write and fact-check →