What Is OAuth? Delegated Access, Tokens, and PKCE Flows
Scrapeless Agent Browser supports browser navigation and session-based workflows, while OAuth permissions remain the responsibility of the application and authorization server.
TL;DR
- OAuth delegates access to protected resources. It does not define a universal user-login assertion for every application.
- Authorization codes and access tokens have different roles. A code is exchanged at the token endpoint; an access token is used with a resource service.
- PKCE binds a code exchange to its initiating client transaction. Public applications cannot safely rely on an embedded shared secret.
- Browser automation does not create delegated permission. Use only accounts and actions the resource owner has authorized.
OAuth Is a Framework for Delegated Authorization
OAuth is an authorization framework that lets an application obtain limited access to protected resources without collecting the resource owner’s password for those resources. A user can authorize a scheduling tool to read a calendar, for example, while the calendar service controls the permitted operations. The scheduling tool receives a credential for that access rather than the user’s reusable password.
The OAuth authorization framework defines the roles and core interactions. The resource owner controls the relevant resource, the client application requests access, the authorization server grants credentials under its policy, and the resource server hosts the protected API. One organization can operate both server roles, but keeping the roles distinct helps explain where authentication, permission decisions, and token validation occur.
A token grant is narrower than blanket permission to operate an account. Access can be constrained by scope, intended resource, duration, and the authorization server’s policy. The resource server still checks whether the operation is permitted. A consent screen describes the requested access, while the actual granted credential and server enforcement determine what the application can do after consent.
Authorization and Authentication Answer Different Questions
Authorization determines what access an application may exercise; authentication establishes an identity in a particular context. OAuth can involve a user signing in at the authorization server, but that interaction does not automatically give the client a standardized identity assertion suitable for its own login system. Treating an arbitrary access token as proof of login can create token-substitution and audience problems.
The OpenID Connect identity layer adds authentication on top of OAuth and defines an ID token for the client to validate. An access token is intended for a resource service, while an ID token addresses the client’s authentication context. The distinction is visible in the standards and should remain visible in the application design. Sending an ID token to an unrelated API is not equivalent to presenting the correct access token.
For a sign-in product, select a provider integration that explicitly supports the required identity protocol and validate its tokens using that protocol. For delegated API access, request the minimum appropriate permissions and send the resulting access credential only to its intended service. A single user-facing button can hide both workflows, so inspect the actual contract rather than naming every social sign-in action simply OAuth login.
An Authorization Code Separates Browser Consent from Token Use
The authorization code flow routes the user through the authorization server, which authenticates the user as needed and evaluates the access request. After approval, the browser returns to the registered client redirect location with a short-lived authorization code. The client then exchanges that code at the token endpoint using the parameters and authentication appropriate to its client type.
A code is not the API credential used to read calendar entries or other protected records. Its purpose is to connect the front-channel authorization interaction with the subsequent token exchange. Keep redirect URI validation strict and bind the response to the transaction the client initiated. A callback received at an unexpected origin or without the expected transaction context should not become an authenticated application session.
A client registration describes details such as its redirect locations and permitted grants. A server application that can protect credentials and a browser-delivered public application have different capabilities. Do not copy a server-side client secret into downloadable JavaScript. The application’s distribution model determines whether that value can be held confidentially, regardless of the label attached to it in a dashboard.
PKCE Protects the Code Exchange
PKCE, or Proof Key for Code Exchange, binds the authorization request and token exchange using a transaction-specific verifier. The client derives a challenge from the verifier and includes the challenge in the authorization request. At the token endpoint it supplies the verifier, allowing the server to confirm that the exchange belongs to the same initiating transaction.
The PKCE mechanism addresses interception of authorization codes. PKCE does not turn a public application into a confidential client, and the verifier is not a permanent client password. Generate and retain it within the specific transaction, keep it protected, and use a supported challenge method that does not expose the verifier in the authorization request.
The current OAuth security best practice requires PKCE for public clients in the authorization code flow and recommends it for confidential clients. It also addresses exact redirect matching, code injection, and token leakage. Apply those requirements through a maintained OAuth implementation rather than assembling a flow from loosely related snippets. Correct libraries still need correct issuer, redirect, and resource configuration.
| Artifact | Intended Role | Common Confusion |
|---|---|---|
| Authorization code | Input to a token exchange | Using it directly as an API access credential |
| Access token | Credential for an intended resource server | Treating it as a universal user identity assertion |
| Refresh token | Credential for obtaining access tokens at the authorization server | Sending it to a business API |
| ID token | OpenID Connect identity assertion for the client | Using it as a replacement for an API access token |
| PKCE verifier | Transaction-specific proof in the code exchange | Treating it as a permanent client secret |
Access Tokens and Refresh Tokens Have Separate Lifecycles
An access token carries or references the authorization needed by a resource service. Its format is not fixed by the general OAuth framework: a service can use an opaque value or a structured token. The client should rely on documented response fields and resource requirements rather than assuming every access token is a readable JSON Web Token.
A refresh token is a different credential used with the authorization server to obtain access tokens. It should not be sent to the ordinary resource API. Whether the server issues one, how long it remains valid, and what protections apply depend on the client and provider policy. Protect it as a valuable secret because its lifecycle may extend beyond that of a single access token.
Revocation also has a defined interface rather than being implied by deleting a local string. The OAuth token revocation mechanism allows a client to notify the authorization server that a token is no longer needed. Local logout, grant revocation, and termination of every application session can have different effects. Document those effects so users understand what disconnecting an integration actually changes.
Scope, Audience, and Server Policy Limit Access
Scopes describe requested or granted capabilities within the authorization system’s vocabulary. Their names and meanings belong to the provider. A read-oriented scope may still expose sensitive records, so request only what the product feature requires and explain why. An application should not ask for broad write permissions merely because that makes future development easier.
The intended resource or audience is another boundary. A token issued for one service should not be accepted as interchangeable authorization at another service. Resource servers must validate the relevant issuer, audience, expiry, and authorization details using the selected token mechanism. A valid signature alone does not establish that a credential is appropriate for the requested operation.
Client credentials flows address application access in contexts that do not represent a user’s delegated consent. Device-oriented flows address other interaction constraints. Choose a grant supported for the actual application type rather than forcing all products through one familiar flow. The presence of OAuth in a service’s documentation does not mean every grant, scope, or client type is available to every account.
Keep Browser State Separate from OAuth Credentials
Browser cookies, an application session, and OAuth credentials are related implementation concerns with different lifecycles. A browser can remain signed in while an API token expires, and an application can hold a valid delegated token after a particular browser view closes. Diagnose permission failures at the component that owns the relevant credential rather than copying browser state into unrelated services.
Scrapeless Agent Browser provides a browser environment for authorized automation. Its session-based automation overview does not create an OAuth grant for a third-party account. An automated workflow must preserve the same resource-owner consent, application permissions, and service access conditions expected of a person using the interface. An access denial remains a permission decision to resolve through the owning application.The Scrapeless API key handling requirements describe a separate credential used to access Scrapeless products. A Scrapeless API key is not an OAuth access token for the target website. The related API authentication methods help distinguish credential schemes, and Scrapeless pricing covers service usage rather than third-party authorization rights.
Review a Delegated Integration Before Expanding It
A delegated integration should have a clear permission inventory. Record the issuer, intended resources, requested scopes, client type, redirect locations, credential storage, and disconnect behavior. Separate ordinary application telemetry from token-bearing request data so routine logs do not become an uncontrolled credential store. Test permission boundaries with authorized accounts and documented access levels.
A hypothetical calendar integration can begin with read-only access for one user-approved feature. Its acceptance criteria should include the correct account, permitted calendar resources, a working disconnect path, and the absence of secrets in client-visible logs. Expand permissions only when a concrete feature requires them. That discipline makes the consent request easier to explain and limits the consequences of a credential exposure.
Conclusion
OAuth delegates specific access through defined roles, credentials, and server policy. Choose the flow for the actual client type, use PKCE where required, and keep identity assertions separate from resource access tokens. A maintainable integration makes its scopes, storage boundaries, and disconnect behavior clear before it handles sensitive account data.
Build Your Web Data Workflow
Use Agent Browser for permitted browser workflows while your application preserves the target service’s consent and credential boundaries.
Sign up today and get $5 in free credit — no credit card required.
Claim Your $5 Credit →FAQ
Is OAuth an authentication protocol?
OAuth is primarily an authorization framework. A user may authenticate at the authorization server during a flow, but OAuth alone does not define a universal identity assertion for the client. OpenID Connect adds a standardized identity layer for sign-in use cases.
Does PKCE replace every client secret?
PKCE does not replace every client secret. It binds an authorization code exchange to a specific initiating transaction. Confidential clients may still authenticate at the token endpoint, while public clients cannot safely depend on a shared secret embedded in distributed application code.
Are OAuth access tokens always JWTs?
OAuth access tokens are not always JWTs. A provider can issue opaque or structured credentials. Follow the provider’s validation and resource-access contract, and do not decode or construct token values based only on their appearance.
Can a refresh token be sent to a resource API?
A refresh token belongs at the authorization server’s supported token interface, not at an ordinary resource API. Keep its storage, access, and lifecycle separate from routine resource requests. The provider determines whether the application is eligible to receive it.
Does browser automation grant OAuth permissions?
Browser automation does not grant OAuth permissions by itself. Resource-owner consent and server policy still determine the authorized operations. Use only accounts and actions within the approved scope, and keep the browser platform’s own credential separate from credentials issued by the target service.