TL;DR: OAuth 2.0 is an authorization framework that allows an app to access a user’s data without requiring the user’s password. It works through roles, scopes, and tokens, and it is widely used in APIs, mobile apps, Google integrations, and enterprise platforms.

If you have ever clicked “Continue with Google”, allowed a calendar app to access your Google Calendar, or connected one SaaS tool to another, you have already seen an example of OAuth in action.

OAuth 2.0 was designed to allow applications to obtain limited access to protected resources without handling a user’s password directly. In the core IETF specification, OAuth 2.0 is defined as a framework that lets a third-party application obtain limited access to an HTTP service, either on behalf of a resource owner or on its own behalf.

That distinction matters. OAuth is not primarily a “login protocol.” It is an authorization framework. When teams misuse it as a substitute for identity, architecture problems usually follow. That is why modern implementations often pair OAuth with OpenID Connect, which adds an identity layer on top of OAuth 2.0.

For developers, architects, and security teams, understanding what OAuth 2.0 is and how does OAuth 2.0 works is foundational. It sits behind API access, mobile sign-in, delegated permissions, machine-to-machine communication, and many cloud integrations.

What is OAuth 2.0?

At its core, OAuth 2.0 is a mechanism for delegating access. Instead of giving an application your password, you grant that application a defined level of access to a protected resource. The authorization server issues a token, and the client uses that token to call the resource server.

A simple way to understand what is OAuth 2.0: it is a framework for allowing one system to act with limited permissions on another system’s data.

Key OAuth Concepts

  • Resource Owner: Usually the user who owns the data
  • Client: The application requesting access. This might be a web app, a mobile app, a single-page app, or a backend service
  • Authorization Server: The server that authenticates the user, gathers consent, and issues tokens
  • Resource Server: The API or service that hosts the protected data and accepts access tokens
  • Scope: A named permission that limits what the client can access. Google’s OAuth documentation emphasises that scopes determine the level of access being requested, and some scopes are classified as sensitive
  • Access Token: A credential used to access protected resources. RFC 6750 defines bearer tokens for OAuth 2.0 and notes that any party holding a bearer token can use it, which is why these tokens must be protected in storage and transit
  • Refresh Token: A token used to obtain a new access token without forcing the user through the consent flow again. Google’s server-side OAuth documentation explicitly includes refresh tokens as part of the model

How OAuth 2.0 Works: Step-by-Step

How OAuth 2.0 Works

  1. The user requests access through an app: The process begins when a user clicks an option such as Sign in with Google or Connect with Microsoft on a website or app. This tells the app that the user wants to use a third-party account.
  2. The app redirects the user to the authorization server: The app sends the user to the authorization server of the provider, such as Google, Facebook, GitHub, or Microsoft. This is where the user will log in and approve access.
  3. The user logs in and grants permission: The user signs in to the provider account and sees a consent screen. This screen explains what information or actions the app wants access to, such as profile details, email, contacts, or calendar data.
  4. The authorization server sends back an authorization code: If the user approves the request, the authorization server sends an authorization code back to the application. This code is temporary and is used to request an access token.
  5. The app exchanges the code for an access token: The application sends the authorization code to the authorization server. In return, it receives an access token and, sometimes, a refresh token.
  6. The app uses the access token to request data: The application sends the access token to the resource server, which hosts the user’s protected data. The token proves that the app has permission to access the requested information.
  7. The resource server verifies the token: The resource server checks whether the token is valid, active, and has the correct permissions. If everything is valid, the requested data is returned to the app.
  8. The app accesses the allowed resource: Once the token is accepted, the application can perform the permitted action, such as displaying a profile, accessing files, or syncing calendar events.

Integrating OAuth With Google API

Google is one of the most practical places to learn OAuth because its documentation is detailed and its APIs use standard OAuth 2.0 flows.

A typical Google API integration looks like this:

  • Create a project in Google Cloud
  • Enable the API you want, such as Drive or Calendar
  • Configure the OAuth consent screen
  • Create OAuth client credentials
  • Request only the scopes you need
  • Exchange the authorization code for tokens
  • Use the access token to call the API

Google’s documentation also distinguishes between application types such as web server apps, JavaScript apps, native apps, and server-to-server use with service accounts.

How to Build Your First OAuth App

Your first OAuth app does not need to be complex. The core steps are standard across most providers.

  • First, register the app with the provider to obtain a client ID and, for confidential clients, a client secret. Then define a redirect URI that the authorization server is allowed to use for callback.
  • Next, send the user to the authorization endpoint with values like client_id, redirect_uri, response_type=code, and scope. After consent, the app receives an authorization code and exchanges it at the token endpoint for an access token.
  • Finally, the app calls the protected API with that token.

For Node.js, Google’s officially supported client libraries for Node.js include OAuth helpers. The Google Auth Library for Node.js is Google's supported Node.js client library for OAuth 2.0 authorization and authentication with Google APIs, and the broader Google API Node.js client includes an OAuth2 client that can retrieve, refresh, and reuse tokens.

So if you want to implement OAuth 2.0 in Node.js, the practical route is usually:

  • Use a maintained OAuth client library
  • Store redirect URIs and client secrets securely
  • Exchange codes only on the backend when appropriate
  • Keep access and refresh token handling out of unsafe client-side storage
Learn 29+ in-demand AI and machine learning skills and tools, including Generative AI, Agentic AI, Prompt Engineering, Conversational AI, ML Model Evaluation and Validation, and Machine Learning Algorithms with our Professional Certificate in AI and Machine Learning.

Why Use OAuth 2.0 for Security

OAuth 2.0 improves security by preventing password reuse, limiting access via scopes, supporting short-lived credentials, and allowing permissions to be revoked.

Those traits are built into the model described by the IETF specification and reinforced by modern best-practice guidance.

A bearer token is still sensitive, though. RFC 6750 makes that explicit: whoever possesses the token can use it unless additional protections are in place. That is why HTTPS, secure storage, careful scope design, and token expiration matter so much.

PKCE is another major security improvement. RFC 7636 describes it as a mitigation for authorization code interception attacks in public clients. RFC 8252 then applies that guidance to native apps and says authorization requests from native apps should go through an external user-agent, primarily the user’s browser.

Common Pitfalls to Avoid

  • One of the biggest OAuth mistakes is treating it as a standalone authentication mechanism. OAuth grants access; OpenID Connect verifies identity. The OpenID Foundation’s core specification is very clear that OpenID Connect is an identity layer on top of OAuth 2.0. 
  • Another mistake is over-requesting scopes. Google warns that scope choice affects sensitivity and review requirements, so the principle of least privilege matters in real deployments.
  • Other common issues include weak redirect URI validation, unsafe token storage, failure to use HTTPS, and reliance on legacy flows, even though newer best practices recommend safer alternatives.

Real-World Applications of OAuth

OAuth is used wherever delegated API access is needed.

  • Social login is the most visible consumer example, but it is only one part of the picture
  • Google documents OAuth across browser, native, web server, and server-to-server applications

That means OAuth supports everything from “Sign in with Google” to service accounts calling backend APIs without human interaction.

A strong example of OAuth is a calendar scheduling app that asks for permission to read a user’s Google Calendar. The app does not get the Google password. Instead, it receives a token with the scopes the user approved.

Did You Know? The global artificial intelligence market is projected to reach USD 3,497.26 billion by 2033, expanding at a CAGR of 30.6% from 2026 to 2033. (Source: Grand View Research)

Future: OAuth 2.1 Updates

OAuth 2.1 remains an active IETF draft rather than a finalised RFC. The draft states that it obsoletes the original OAuth 2.0 framework and bearer token usage documents and consolidates the protocol with more modern guidance.

In reality, its direction is clear: remove weaker patterns, align with the security best current practices, and standardise safer defaults, such as PKCE-centric flows.

That means teams designing systems in 2026 should treat OAuth 2.1 less as a brand-new protocol and more as the cleaned-up, security-hardened version of what mature OAuth implementations are already moving toward.

JWT vs OAuth: One Important Clarification

Since JWT vs OAuth is a frequent search query, it is worth being precise: JWT and OAuth are not competing alternatives. OAuth is an authorization framework. JWT is a token format defined by RFC 7519. In other words, OAuth describes how access is delegated, while JWT describes one possible way to package claims inside a token. Some OAuth deployments use opaque tokens; others use JWT-formatted tokens.

You can also watch this video for a deeper understanding of what is OAuth 2.0 and how it works. Watch Now!

FAQs

1. What is an example of OAuth 2.0?

A common OAuth 2.0 example is Sign in with Google. You approve access, and the app receives a token to access allowed information without getting your Google password.

2. How does OAuth 2.0 work in REST API?

In a REST API, the client obtains an access token from the authorization server and sends it with API requests to the resource server to access protected data.

3. What are the main roles in OAuth 2.0?

The main OAuth 2.0 roles are resource owner, client, authorization server, and resource server. Together, they manage permission, token issuance, and protected resource access.

4. What is an access token in OAuth 2.0?

An access token is the credential a client uses to call a protected resource. It represents granted authorization and lets the app access approved data or actions.

5. What are OAuth 2.0 grant types?

OAuth 2.0 grant types are mechanisms by which a client obtains authorization. RFC 6749 defines the authorization code, implicit, resource owner password credentials, and client credentials grant types, as well as extension grants. Newer guidance deprecates some older flows

Our AI & Machine Learning Program Duration and Fees

AI & Machine Learning programs typically range from a few weeks to several months, with fees varying based on program and institution.

Program NameDurationFees
Professional Certificate in AI and Machine Learning

Cohort Starts: 23 Apr, 2026

6 months$4,300
Professional Certificate Program inMachine Learning and Artificial Intelligence

Cohort Starts: 23 Apr, 2026

20 weeks$3,750
Microsoft AI Engineer Program

Cohort Starts: 27 Apr, 2026

6 months$2,199
Oxford Programme inStrategic Analysis and Decision Making with AI

Cohort Starts: 14 May, 2026

12 weeks$3,390