What is OAuth?

OAuth is a framework that lets an application obtain limited access to a protected service. It can act on behalf of a user, or in some cases on its own behalf, using an access token rather than asking the user to share their service password with the application.
For example, a reporting tool might be allowed to read selected information from another service without receiving permission to change or delete it. The access depends on what the authorisation server grants and what the API actually enforces. OAuth does not automatically make an application trustworthy or its requested permissions appropriate.
This guide focuses on OAuth 2.0 and its security guidance. OAuth is primarily about delegated access. A familiar sign-in button may use OpenID Connect alongside OAuth, but OAuth by itself is not a complete standard protocol for identifying the person who has signed in.
The problem OAuth solves
Without a suitable delegation mechanism, a third-party application might ask for a user's password to access another service. That exposes a powerful credential and makes it difficult to limit what the application can do. OAuth separates the application's access from the user's original credentials.
RFC 6749, the OAuth 2.0 authorisation framework, defines the principal roles and grant mechanisms. Its original 2012 text must be read with later security updates, rather than treating every flow it describes as suitable for a new implementation.
The resource owner controls or is entitled to authorise access to a protected resource. The client is the application requesting access. The authorisation server issues tokens after the required checks, and the resource server is the API or service that accepts valid access tokens. One product may perform several of these roles.
How an OAuth code flow works
A common modern design uses the authorisation-code flow with PKCE, pronounced “pixy”. The user interacts with the service's authorisation system, and the application obtains tokens through the token endpoint. A short-lived code is an intermediate credential, not the API access token itself.
The illustration shows a simplified authorisation-code flow: request limited access, authorise it, exchange the code and call the API. PKCE and other validation checks remain essential implementation details even though they are not all shown in the graphic.

The application starts an authorisation request with its client identifier, registered redirect location and requested access.
The authorisation server authenticates the user where required and determines whether access should be granted under consent and policy.
The browser returns to the application with an authorisation code through the supported flow.
The application exchanges the code at the token endpoint, supplying the required PKCE verifier and client authentication where applicable.
The application sends the resulting access token to the intended API.
The API validates the token and enforces the permitted operations and resource boundaries.
The exact messages depend on the grant and implementation. An approval screen is not guaranteed on every request: a previous grant or organisational policy may affect the interaction. The application should explain what it needs, and users or administrators should review the actual permissions.
The four OAuth roles
Role | Responsibility | Illustrative example |
|---|---|---|
Resource owner | Can authorise access to a protected resource | Person granting access to their reports |
Client | Requests and uses delegated access | A reporting application |
Authorisation server | Evaluates the grant and issues tokens | The service's authorisation platform |
Resource server | Validates access and serves protected data | A reports API |
The authorisation server and API need compatible trust and token-validation arrangements. A token issued by an unexpected server, intended for a different API or carrying insufficient access must not be accepted just because it looks correctly formatted.
OAuth, authentication and OpenID Connect
Authorisation determines whether an action is permitted. Authentication checks a claimed identity or credential. OAuth can involve authenticating a user at the authorisation server, but the OAuth framework does not by itself define how a client obtains a standard authentication statement about that user.
OpenID Connect adds an identity layer on top of OAuth 2.0. It defines an ID token and validation rules for the application relying on the authentication. An OAuth access token and an OpenID Connect ID token have different intended purposes and recipients.
An identity provider may provide OpenID Connect sign-in and OAuth authorisation in one platform. That does not make every token interchangeable. A client should not use an arbitrary access token, or merely decode a field containing an email address, as proof of a valid login.
Single sign on is also a separate concept. It lets connected applications rely on a common sign-in system. OAuth can be part of that wider system, while each application still needs correct session handling and permissions.
Codes, access tokens and refresh tokens
Credential | Purpose | Handling requirement |
|---|---|---|
Authorisation code | Intermediate grant exchanged for tokens | Short-lived and single-use under the protocol |
Access token | Access to a protected resource | Send only to its intended recipient and protect from leakage |
Refresh token | Obtain replacement access tokens where supported | Protect carefully; apply the server's rotation and revocation rules |
ID token | Communicate authentication in OpenID Connect | Validate for the relying application; do not use as a general API token |
An access token is not required to be a JWT. It may be opaque to the client, with the API using the agreed validation mechanism. Even when it is a JWT, reading its contents is not the same as checking its signature, issuer, audience, expiry and applicable permissions.
A bearer token can generally be used by whoever possesses it, subject to the server's checks. Sender-constrained token mechanisms can require additional proof, but they need explicit support. Do not assume every OAuth deployment binds tokens to a particular device or application instance.
Refresh tokens are not sent to the resource API as substitutes for access tokens. They are used with the authorisation server, where issued, and their availability and lifetime depend on the client and policy. Some grants or deployments do not provide them.
Scopes and API permissions
Scopes describe requested or granted access using strings whose meanings are defined by the authorisation server and resource service. They are not universal permission names across every provider. A token with a scope that looks broad still needs to be interpreted according to the API's rules.
Least privilege means asking for only the access needed, using the appropriate resource or audience restrictions and enforcing permissions at the API. A scope such as read access does not automatically decide which individual customer's records the client may read. Object-level and tenant-level checks may still be required.
Consent is not a guarantee of safety. A user can approve a malicious application or an excessive permission request. Review the application's identity, why it needs access, who can approve it and how the grant can later be removed.
What PKCE protects
PKCE binds an authorisation request to a later code exchange. The client creates a high-entropy verifier and sends a derived challenge in the initial request. When redeeming the code, it supplies the verifier so the server can check that it matches.
RFC 7636 defines this mechanism. An intercepted code should not be redeemable by someone who lacks the required verifier. Use a fresh verifier for each transaction and the supported secure challenge method, normally S256, through a maintained library.
PKCE does not make a public client capable of keeping a permanent secret. Browser and native applications cannot rely on an embedded client secret remaining confidential. A client identifier is also not a secret. Confidential server-side clients can use supported client authentication in addition to the appropriate flow protections.
Which flows should a new application use?
The right grant depends on the task. Authorisation-code flow with PKCE is a common choice for interactive user delegation. Client credentials can suit a confidential application acting on its own behalf. Device authorisation can support devices with limited input, but requires its own supported flow and careful user verification.
The OAuth 2.0 Security Best Current Practice, RFC 9700, published in January 2025, updates earlier advice. It requires PKCE for public clients in code flows, recommends it for confidential clients and says the resource owner password credentials grant must not be used. Clients should avoid the implicit access-token flow under its stated guidance.
Do not copy an old tutorial that asks the client to collect the user's service password or exposes access tokens in redirect URLs without considering current guidance. Use the provider's supported modern integration and maintained libraries.
OAuth 2.1 is intended to consolidate modern practice. At the time of this article's October 2026 research, the IETF still listed it as an Internet-Draft, rather than a published RFC. Implementations should distinguish draft adoption from established OAuth 2.0 specifications and published security updates.
A practical example: a UK reporting service
Imagine a UK technical support business connecting a reporting tool to a monitoring API. This is a hypothetical design, not a tested configuration or a claim about a specific product.
The tool needs to read selected reports, not change network configuration. The user completes the provider's authorisation process, and the client receives access suitable for that API. The API must check both the token and whether the requested report belongs within the permitted account or tenant.
Request | Intended result | What must be checked |
|---|---|---|
Read an authorised report | Allow within the granted access | Token, API audience and resource permissions |
Change network configuration | Deny without the required permission | The API enforces the action boundary |
Read another customer's report | Deny unless separately authorised | Object and tenant boundaries |
Continue after grant removal | Follow the documented revocation behaviour | Existing tokens, refresh and caches |
The useful question is whether the complete request is allowed, not just whether the application has a token. A correctly issued token can still be misused if the API fails to enforce the customer's resource boundary.
Expiry, revocation and logout
Access tokens should have an appropriate lifetime, but there is no universal duration suitable for every deployment. Refresh-token policy and sender-constraining can affect the risk. Choose based on the application's security and operational requirements.
Removing a grant, revoking a refresh token and logging out of an application are different actions. Their effects on existing access tokens depend on implementation, token validation and caching. Do not promise immediate loss of all access without testing the actual system.
A locally validated token may remain acceptable until expiry unless the API has an additional revocation mechanism. An API using introspection can obtain token status from the authorisation server, subject to its own caching and availability design. Both approaches need explicit operational choices.
How to review an OAuth integration
Identify the client type, grant, authorisation server and intended API.
Confirm exact redirect registration and supported transaction protections.
Request minimal scopes and resource access; verify what is actually granted.
Validate tokens at the correct component and enforce action, object and tenant permissions.
Protect tokens, client credentials and refresh-token storage from leakage.
Test failed exchanges, wrong audiences, expired tokens and denied actions.
Test refresh, grant removal, revocation, logout and provider outages.
Use authorised test accounts and non-sensitive data. Avoid putting live tokens, codes or secrets in logs, screenshots, browser URLs or public troubleshooting tools. If sensitive credentials have leaked, follow the provider's incident and revocation procedures rather than only deleting the visible copy.
Common OAuth problems
Redirect mismatch: the return location does not match the registered configuration.
Code exchange fails: the code has expired, was already used or does not match the client, redirect or PKCE verifier.
API rejects the token: issuer, audience, expiry or the validation mechanism does not match the API.
Token accepted but action denied: granted access or application permissions are insufficient.
Refresh fails: the refresh token is expired, revoked or invalidated by the rotation policy.
Access remains after logout: the application session and API token lifecycle are not the same thing.
Trace the specific stage using client, authorisation-server and API logs together. Capture non-sensitive correlation information and timing. A working login page does not prove a code exchange or resource request is correct.
Key takeaway
OAuth provides controlled access through tokens. Safe implementation depends on the grant, redirect and code protections, minimal permissions, secure token handling and API enforcement. Use OpenID Connect where standard user authentication is required, and test the full lifecycle rather than stopping when a token is issued.
Frequently asked questions
What is OAuth used for?
OAuth lets an application obtain limited access to a protected service, on behalf of a user or, in supported cases, on its own behalf.
Is OAuth an authentication protocol?
OAuth primarily defines delegated access. OpenID Connect adds a standard identity layer for user authentication on top of OAuth 2.0.
Does OAuth share my password with the application?
Modern user-delegation flows let the application obtain tokens without receiving the user's service password. The obsolete password grant should not be used.
Is every OAuth access token a JWT?
No. Access tokens can be opaque or use a structured format. The API must use the validation mechanism agreed with the authorisation server.
What does PKCE do?
PKCE binds an authorisation request to its code exchange using a verifier and derived challenge, helping prevent misuse of an intercepted authorisation code.
Is a client ID a secret?
No. A client ID identifies an application registration. It is distinct from confidential client credentials and does not by itself authenticate a client.
Does logging out immediately revoke all OAuth tokens?
Not necessarily. Application sessions, access tokens, refresh tokens and grants have different lifecycles. Test the provider and API's actual behaviour.

