OAuth

OAuth is an authorization framework that lets an application access limited data or perform approved actions on another service without receiving the user's password. It uses scoped, revocable tokens to delegate access, rather than sharing account credentials. Although people often call it OAuth authentication, OAuth itself governs permissions; OpenID Connect commonly adds identity verification for sign-in.

What Is OAuth?

OAuth is an authorization framework that lets an application access limited data or perform approved actions on another service without receiving the user's password. It uses scoped, revocable tokens to delegate access instead of sharing account credentials.

OAuth stands for Open Authorization. In everyday use, it is what makes a prompt such as “Allow this calendar app to view your events?” possible. OAuth 2.0, also called OAuth2 or OAuth 2, is the widely used modern family of specifications for this type of delegated access. The core framework is described in RFC 6749, with later security guidance and extensions shaping current practice.

The important idea is separation. A user keeps their password with the service that manages their account, while another app receives a limited permission to use a particular API.

OAuth Is Authorization, Not Authentication

Authentication proves who someone is. Authorization determines what an authenticated person or application is allowed to access or do. OAuth is primarily about authorization.

The phrase “OAuth authentication” is common, but it can be misleading. A “Sign in with” button may use OAuth to obtain permission to call an API, while OpenID Connect adds a standard identity layer that tells the application who signed in. An app should not treat a general OAuth access token as proof of a user's identity unless the provider explicitly documents that design.

The Four OAuth Roles and Key Components

OAuth separates responsibilities among four roles. The resource owner is the person or organization that owns the data. The client is the app requesting access. The authorization server authenticates the user, records consent, and issues credentials. The resource server hosts the protected API, such as a calendar, file store, or email service.

A client ID identifies the app to the provider. A redirect URI is the pre-registered address to which the provider sends the user after approval. Scopes describe requested permissions, such as reading calendar events but not editing them. Consent is the user's decision to grant those scopes.

In a common flow, the provider returns a short-lived authorization code to the redirect URI. The app exchanges that code for an access token, which it presents to an API. A refresh token may allow the app to obtain a new access token later without requiring the user to approve again. Refresh tokens need stronger protection because they can provide longer-term access. Tokens may be opaque strings that only the provider can interpret, or structured JSON Web Tokens, known as JWTs.

PKCE, pronounced “pixy,” adds a cryptographic check between the initial authorization request and token exchange. It helps stop an intercepted authorization code from being used by another app.

How Does OAuth 2.0 Work?

OAuth 2.0 commonly uses the authorization code flow with PKCE. For example, a photo-printing app might ask for permission to view selected photos stored with another provider.

  1. The photo-printing app creates an authorization request containing its client ID, requested scopes, redirect URI, a state value, and PKCE information.
  2. The app sends the user to the provider's authorization server.
  3. The user signs in directly with the provider, not with the photo-printing app.
  4. The provider displays the requested permissions and the user approves or declines them.
  5. If approved, the provider redirects the user to the registered redirect URI with a temporary authorization code and the state value.
  6. The app verifies the state value and exchanges the code, along with its PKCE verifier, for an access token and sometimes a refresh token.
  7. The app sends the access token to the photo API and receives only the data permitted by the approved scopes.
  8. When the access token expires, the app may use its refresh token to obtain another one, or the user or provider can revoke access at any time.

OAuth Tokens, Scopes, and Consent

An access token is a temporary credential for calling a protected API. It should expire relatively quickly, limiting harm if it is exposed. A refresh token exists to obtain replacement access tokens and is therefore more sensitive. Some applications do not receive refresh tokens at all.

Scopes are the boundary of a grant. A request for “read contacts” is narrower than a request for complete account control. Good systems use incremental authorization, asking for additional access only when a user tries to use a feature that needs it. Consent is meaningful only when the request clearly explains what the scopes allow.

The practical rule is least privilege: request the smallest set of permissions, for the shortest practical time, needed to deliver the feature.

OAuth 2.0 Flows and When to Use Them

The correct flow depends on whether a person is granting access and whether the app can safely keep a secret. Modern applications should avoid older patterns unless a provider requires them for a specific legacy case.

Flow or mechanismBest useKey point
Authorization code flow with PKCEWeb, mobile, desktop, and browser-based apps acting for a userRecommended modern default for user-delegated access.
Client credentialsService-to-service API accessNo user consent step. The client acts as itself, not as a user.
Device authorization grantSmart TVs, consoles, and devices with limited inputThe user approves access on a separate phone or computer.
Refresh tokenMaintaining authorized access over timeUsed after an initial grant, not as a replacement for secure authorization.
Implicit flow and password grantLegacy implementationsNew implementations should generally avoid these patterns because safer alternatives exist.

OAuth vs. OpenID Connect, SAML, JWTs, and API Keys

These technologies often appear together, but they solve different problems. Asking whether OAuth is better than JWT, or whether SAML is better than OAuth, usually compares tools with different purposes.

TechnologyMain purposeProves identity?Important limitation
OAuthDelegated API authorizationNo, not by itselfIt does not standardize user identity claims.
OpenID ConnectAuthentication and sign-in on OAuthYesIt still needs careful token validation.
SAMLEnterprise single sign-onYesOften less convenient for modern mobile and API scenarios.
JWTA token formatSometimes, depending on claims and validationJWT is not an authorization protocol.
API keyIdentify an application or simple API accessNoUsually lacks user consent and granular delegated permissions.

Single sign-on, or SSO, is an outcome in which one login works across services. OpenID Connect or SAML can provide SSO. OAuth can support an integrated experience, but it is not itself an SSO standard.

Common OAuth Use Cases

OAuth is useful whenever one service needs carefully bounded access to another service's API.

  • Social and enterprise sign-in, when OAuth is paired with OpenID Connect.
  • Calendar, email, contact, and cloud-file integrations.
  • Connected productivity tools that synchronize selected data between services.
  • Mobile apps that need access to a user's account on an external platform.
  • Smart TVs and other limited-input devices using device authorization.
  • Service-to-service API access using client credentials.
  • Apps built through modern app design and development processes that integrate external APIs without collecting user passwords.

Benefits of OAuth

OAuth can improve both user experience and security when the provider and client implement it correctly.

  • Passwords stay with the account provider rather than being shared with every connected app.
  • Scopes can limit access to particular data or actions.
  • Access tokens can expire, reducing the value of an exposed token.
  • Users and providers can revoke a connected app without changing the account password.
  • Centralized consent gives users a clear approval point.
  • Standard flows make third-party integrations more consistent.
  • Appropriate logging can support auditing of token issuance, consent, and API use.

Practical Limits and Common OAuth Pitfalls

OAuth is not automatically safe just because a consent screen appears. Its protection depends on careful implementation, trusted providers, and informed user choices.

  • Phishing sites can imitate a provider's sign-in or consent page to steal credentials or approval.
  • Overly broad scopes can give an app far more access than its feature needs.
  • Tokens can be compromised through application logs, browser storage, malicious extensions, insecure devices, or leaked backups.
  • Loose redirect URI matching can send authorization codes to an attacker-controlled destination.
  • Skipping PKCE allows certain authorization-code interception attacks.
  • Failure to validate state can enable request forgery. Identity flows also need nonce and issuer validation where applicable.
  • An access token should not be mistaken for proof that a user signed in to the client application.
  • Long-lived refresh tokens increase the impact of theft if rotation and revocation are weak.
  • Providers vary in token format, scope names, expiry rules, and revocation behavior, so assumptions do not always transfer across platforms.

OAuth Security Checklist for App Teams

Security decisions should be made early, not added after an integration works in testing. Teams using hosted or no-code backend tools still need to configure OAuth settings carefully.

  • Use authorization code flow with PKCE for public clients such as mobile and browser apps.
  • Register exact redirect URIs and do not accept arbitrary return addresses.
  • Validate state on authorization responses, plus nonce for applicable OpenID Connect requests.
  • Store tokens securely and keep them out of URLs, analytics events, error reports, and logs.
  • Request the minimum scopes needed for each feature.
  • Use TLS for every authorization, token, and API request.
  • When validating JWTs, verify signature, expiry, audience, issuer, and other documented claims.
  • Rotate client secrets, protect them from source repositories, and use maintained provider libraries.
  • Support revocation, refresh-token rotation where available, and a clear reconnect process.

What Users Should Check Before Granting OAuth Access

Users remain an important part of OAuth security. Treat a consent screen as a permission decision, not a routine click-through step.

  • Confirm that the app and provider domain are spelled correctly and use the expected official site.
  • Read the requested permissions and question requests for full mailbox, file, or account access.
  • Choose a narrower permission option if the provider offers one.
  • Review connected applications periodically in the account security settings.
  • Remove access for apps that are unused, unfamiliar, or no longer trusted.
  • Use a unique password and multifactor authentication for the provider account.
  • Learn related security terms through the technology glossary before connecting unfamiliar services.

OAuth 1.0, OAuth 2.0, and OAuth 2.1

The name OAuth covers multiple generations. OAuth 2.0 is the practical baseline for modern integrations, while OAuth 2.1 is an ongoing effort to consolidate current secure practice.

VersionStatus and designPractical guidance
OAuth 1.0An older protocol with request signing requirements.Maintain only when a legacy provider requires it.
OAuth 2.0A flexible authorization framework with extensions for many app types.Use modern recommended flows, especially authorization code with PKCE.
OAuth 2.1An effort within the OAuth standards community to consolidate widely adopted security guidance and remove outdated patterns.Follow its direction through current provider documentation and IETF standards work, rather than assuming universal deployment.

Frequently Asked Questions

Your Questions, Answered

This will automatically populate, don't change

Don't change this element unless you know what you are doing

What is OAuth and how does it work?

OAuth lets an app obtain limited permission to call another service's API without receiving the user's password. The user signs in with the provider, approves requested scopes, and the provider gives the app a temporary access token for the approved actions.

What is OAuth 2.0?

OAuth 2.0 is the widely used modern authorization framework for delegated API access. It supports different flows for web apps, mobile apps, devices, and service-to-service connections.

What does OAuth stand for?

OAuth stands for Open Authorization. It is designed to delegate limited access between applications and services.

Is OAuth authentication?

Not by itself. OAuth handles authorization, meaning permissions. OpenID Connect is commonly used with OAuth when an application also needs reliable user authentication and identity information.

Is OAuth risky?

OAuth can reduce password sharing, but it has risks if apps request excessive permissions, tokens are stolen, or users approve a phishing page. Use trusted apps, review scopes, and remove unused connections.

Is OAuth better than JWT?

They are not direct alternatives. OAuth is a protocol for delegated authorization, while JWT is a possible token format. An OAuth system may use JWT access tokens, opaque tokens, or both.

How is OAuth different from SSO?

OAuth delegates access to APIs. SSO lets a user authenticate once and access multiple applications. OpenID Connect and SAML are common technologies for SSO, while OAuth may be part of an integrated sign-in design.

What is PKCE in OAuth?

PKCE is a security extension for authorization code flow. It links the authorization request to the token exchange, helping prevent an intercepted authorization code from being exchanged by an attacker.

How are OAuth tokens compromised?

Tokens can leak through logs, URLs, insecure browser storage, exposed devices, malicious software, or poorly protected backups. Attackers may also obtain them through phishing or weak redirect URI controls.

Which is better, SAML or OAuth?

Neither is universally better because they serve different needs. SAML is often used for enterprise identity and SSO, while OAuth is used to grant limited access to APIs. OpenID Connect is often preferred for modern application sign-in.

Start Building
on Emergent today
Start Building