Browse learn

What Is OAuth 2.0?

Learn how OAuth 2.0 delegates access with clients, resource owners, authorization servers, scopes, and tokens without sharing user passwords.

On this page

Why OAuth 2.0 Matters

When applications need to act on a user's behalf—for example, a calendar app accessing your work calendar—they require access to private data or APIs, but sharing passwords is insecure and unmanageable. OAuth 2.0 exists to solve this problem: it provides a standardized, web-native way for applications to request delegated, limited access to resources, all without the user handing over their credentials. This protocol has become the foundation for secure integrations across modern cloud, web, and API environments.

As organizations span multiple apps and platforms, the risks of ad-hoc credential sharing escalate. OAuth 2.0 delivers a proven framework for delegating access safely, keeping user credentials secure, and making permissions explicit and auditable. For developers, understanding OAuth 2.0 is crucial for building integrations, securing APIs, and ensuring that only the right applications, with the right consent, get the minimal necessary access.

Defining OAuth 2.0: Scope and Purpose

OAuth 2.0, as defined by RFC 6749, is an authorization framework “that enables a third-party application to obtain limited access to an HTTP service.” The protocol lets resource owners (most often users) grant client applications specific, scoped access—such as to read their contacts or access files—while never exposing their actual credentials.

Crucially, OAuth 2.0 does not provide or guarantee authentication. It does not verify a user's identity, only their consent for certain actions. While OAuth 2.0 underpins many login flows, its purpose is to authorize what an app can do, not to confirm who the user is. Where authentication and identity are required, protocols like OpenID Connect extend OAuth 2.0 to fill those gaps.

Key Roles in OAuth 2.0

The framework is built around four well-defined roles:

  1. Resource Owner: Typically a human user who controls the data the client wants to access.
  2. Client: The application requesting access—such as a web app, mobile app, or backend service.
  3. Authorization Server: The system that authenticates the resource owner, requests their consent, and issues access tokens to the client.
  4. Resource Server: The API or backend service hosting the protected resources, enforcing access control via issued tokens.

Example Interaction:
Suppose a user wants a third-party calendar app (client) to access their work calendar (resource server) hosted in a cloud platform. The calendar provider operates an authorization server that handles login and consent. The app directs the user there, the user authenticates and grants specific permissions, and the server returns an access token to the app. The app then uses this token to request calendar data from the resource server. The resource server validates the token, checks the scope, and serves only the permitted data.

OAuth 2.0 Flows: How Does It Work?

OAuth 2.0 prescribes several “flows” (grant types) for clients to obtain access tokens. Each is suited for different application architectures and security requirements. The principal and most secure flows today are:

  • Authorization Code Grant: Used by web and public clients, this flow separates user authentication from token exchange, minimizing token exposure. PKCE (Proof Key for Code Exchange) is now required for public clients such as single-page and mobile apps, adding an essential layer of protection.
  • Client Credentials Grant: Used for server-to-server or machine-to-machine interactions where the client (not a user) needs access.

Deprecated and discouraged flows:

  • Implicit Grant and Resource Owner Password Credentials Grant are now considered insecure, as detailed in RFC 9700. These flows risk exposing tokens or user credentials directly to the client's environment or browser, greatly increasing vulnerability to interception, token theft, or misuse.

Modern best practice is to use Authorization Code Grant with PKCE for any client that cannot reliably protect a client secret, such as browser or mobile apps.

Tokens and Scopes: The Mechanics of Delegated Access

Tokens are the cornerstone of OAuth 2.0:

  • Access Token: A credential issued to the client, presented to the resource server when accessing protected APIs. Its scope and lifetime are limited, enforcing exactly what the client can do and for how long.
  • Refresh Token: Optionally issued to allow the client to obtain new access tokens after the original expires, without requiring the user to reauthorize or re-authenticate.

Scopes tightly define what access is being granted. For instance, a client might request email or calendar.read scopes. The resource server checks the presented token, verifies its validity and scopes, and limits what data or actions are allowed accordingly.

OAuth 2.0 is flexible about token format; tokens may be structured (such as JWTs) or opaque, implementation-defined strings. The only requirement is that their meaning and integrity can be enforced by the resource server.

Practical Use Cases of OAuth 2.0

OAuth 2.0 appears in nearly every significant integration involving third-party or cloud API access:

  • End-user Consent for Third-Party Apps: “Sign in with Google” lets a user grant a site or app access to specific Google account data (e.g., email, contacts), with token-based, revocable consent—credentials never flow through the third-party.
  • App Integrations: SaaS tools like Slack or project management apps can request permission to post messages or sync calendar events, using OAuth 2.0 for permission and secure API access.
  • Machine-to-Machine Interactions: Internal microservices or automation tools use the client credentials grant to operate within strict service boundaries, without user intervention.

In environments governed by centralized directories (like LDAP or Active Directory), OAuth 2.0 can function as an authorization bridge. Here, web or mobile applications obtain standardized, web-native authorization to access APIs that enforce directory-based access policies. The protocol does not replace LDAP or AD itself, but is used alongside those systems to extend secure access controls to modern apps.

OAuth 2.0 Is Not Authentication: Where OpenID Connect Fits

A frequent misconception is that OAuth 2.0 provides authentication. In fact, while the user is often authenticated during the flow (by the authorization server), the protocol does not specify how the client learns who the user is—only that access to a resource was granted by somebody with the needed privileges.

Authentication—proving that a user is who they claim to be—is out of scope for OAuth 2.0. OpenID Connect was designed to fill this gap. As an extension atop OAuth 2.0, it adds standardized identity tokens and user claims, letting clients obtain verifiable information about the user as part of the authorization flow. When you must verify identity (not just authorize actions), OpenID Connect is the protocol to use.

Security, Risks, and Best Practices

The security of OAuth 2.0 implementations depends on following current recommendations:

  • Avoid Deprecated Grant Types: Implicit and Resource Owner Password Credentials grants are obsolete and unsafe. RFC 9700 formally prohibits their use in new deployments.
  • Require PKCE for Public Clients: Always apply PKCE for public clients, including browser apps and mobile clients, to prevent interception and token leakage.
  • Access Token Handling: Treat access tokens as highly sensitive. Do not log them, expose them in URLs, or store them insecurely. For browser-based apps, avoid storing tokens in localStorage or in any location accessible to JavaScript from third-party scripts; such storage is vulnerable to cross-site scripting attacks.
  • Advanced Protections: For environments with heightened security demands, consider mutual TLS (certificate-bound tokens) as described in RFC 8705.
  • Adhere Strictly to Modern Best Practices: RFC 9700 details best practice, including redirect URI validation, CSRF protection, scope minimization, and careful client authentication.

Failure to follow these guidelines exposes systems to token theft, CSRF, privilege escalation, or unauthorized data access. Rely only on methods and flows recommended in the most current RFCs.

Common Misconceptions About OAuth 2.0

  • OAuth 2.0 is an authentication protocol: False. It is a protocol for authorization. It does not standardize identity information or prove user identity.
  • OAuth 2.0 requires JWT access tokens: False. JWTs are commonly used, but OAuth 2.0 tokens can be any format as long as the resource server can validate them.
  • OAuth 2.0 by itself asserts user identity: False. OAuth 2.0 only signals that a client may act with certain rights, not who the user actually is. Identity flows require OpenID Connect or another authentication protocol.

Further Reading and Official References

For full technical details, review the official standards documents:

  • RFC 6749: The OAuth 2.0 Authorization Framework
  • RFC 9700: Best Current Practice for OAuth 2.0 Security
  • RFC 7591: OAuth 2.0 Dynamic Client Registration Protocol
  • RFC 8705: OAuth 2.0 Mutual-TLS Client Authentication and Certificate-Bound Access Tokens

Sources