What is OAuth?

In short
OAuth is an open standard that lets an app get limited access to a user's data on another service without receiving the user's password. The user approves the access, and the app receives a token that it uses in place of the password.
The problem OAuth solves
Imagine you want a photo printing app to read your photos stored on a cloud service. The old way was to hand the app your username and password. The app then had full access to your account, and you had no easy way to limit or revoke that access without changing your password.
OAuth 2.0, described in RFC 6749, fixes this. It is an authorization framework. It lets a third-party application, called the client, obtain limited access to an HTTP service, such as an API, on behalf of the user. The user never shares the password with the app.
Key roles
OAuth names four roles. Knowing them makes the rest of the flow easier to follow.
- Resource owner: the user who owns the data.
- Client: the third-party application that wants access.
- Resource server: the API that holds the protected data.
- Authorization server: the service that checks the user, asks for approval, and issues tokens.
In many real systems, the same company runs the authorization server and the resource server.
How it works
At a high level, the flow looks like this:
- The client sends the user to the authorization server and asks for specific permissions, called scopes.
- The user logs in there and approves or denies the request.
- If approved, the client receives an authorization grant, a credential that proves the approval.
- The client exchanges that grant for an access token.
- The client sends the access token to the resource server with each request.
An access token is a string that represents the permission. The resource server checks it and returns data if it is valid. The client never needs the user's password.
The standard defines several grant types. The authorization code grant is the most common choice for web apps. The client credentials grant is used when an app acts on its own behalf, with no user involved. The implicit and resource owner password credentials grants exist in the specification, but the document itself raises security concerns about them, so new designs should be careful with them.
The specification also describes refresh tokens. A refresh token lets the client get a new access token after the old one expires, without asking the user again.
A simple example
Here is a simplified authorization request for the code grant. The client redirects the user's browser to the authorization endpoint with parameters like these:
GET /authorize?response_type=code&client_id=photo-app&redirect_uri=https://photos.example.com/callback&scope=read_photos&state=xyz123
The parameter response_type=code asks for an authorization code. The state value is a random string the client uses to match the response to its own request and to resist forgery. After the user approves, the authorization server redirects back to the redirect_uri with a code. The client then sends that code, along with its own credentials, to the token endpoint to receive the access token.
The exact parameter names and steps are defined in sections 4.1 and 3.2 of the specification.
Common mistakes
Developers new to OAuth often make a few predictable errors.
- Skipping the state parameter. Without it, the client has weaker protection against cross-site request forgery.
- Requesting more scopes than the app needs. Users are more likely to approve narrow access, and a leaked token then does less damage.
- Storing tokens carelessly. Access tokens and refresh tokens should be treated as secrets.
- Sending requests without TLS. The specification requires Transport Layer Security (TLS, the encryption used by HTTPS) to protect tokens in transit.
- Mixing up authentication and authorization. OAuth is about granting access to resources. It does not, by itself, tell the app who the user is. Systems that need user identity usually add a layer such as OpenID Connect on top.
Alternatives and related ideas
Before OAuth, many services used API keys or shared passwords. API keys work for simple server-to-server calls, but they usually grant broad access and do not identify a user. OAuth 1.0 existed earlier, but RFC 6749 replaces it. Today, OAuth 2.0 is the common base for single sign-on and API access, and most developers meet it through a library or a identity provider rather than writing the protocol by hand.
For a full picture, read the specification's introduction and security considerations, which explain the trade-offs behind each grant type.
FAQ
Is OAuth the same as authentication?
No. OAuth is designed for authorization, which means granting an app limited access to resources. Login and identity checks are a separate concern, which is why many systems pair OAuth with an identity layer.
What is the difference between an access token and a refresh token?
An access token is sent to the resource server to get data and usually expires after a short time. A refresh token is used only with the authorization server to obtain a new access token without asking the user again.
Do I need to write OAuth from scratch?
Usually not. Most frameworks and identity providers include tested OAuth libraries. Understanding the flow still helps you configure them safely and debug problems.
Which grant type should a web app use?
For most web apps with a server-side component, the authorization code grant is the standard choice. Check the specification's security sections before using older grant types.
Sources
This page is based on the official documentation below. Read it for full detail.
OAuth — official documentation ↗OAuth in the news
Google Puts Agent Controls in Workspace APIs: MCP Servers, CLI and Mandatory Routes by 2027
Google made Workspace MCP servers and a Workspace CLI generally available for AI agents, adding per-request policy checks, dedicated agent identities and human confirmation for sensitive actions. Stricter enforcement of the new access rules starts on February 1, 2027.
