AuthenticationOAuth
OAuth 2.0 flows: which grant fits which client
OAuth 2.0 defines several grants for obtaining an access token. RFC 9700 adds PKCE to the authorization code grant, advises against the implicit grant and forbids the password grant.

Client types
RFC 6749 defines two client types. A confidential client can keep its credentials confidential, as a client implemented on a secure server can. A public client cannot. The RFC's examples are an installed native application and an application that runs in a web browser.
Authorization code with PKCE
RFC 6749 describes this grant as a redirection-based flow through the resource owner's user agent.
PKCE is defined in RFC 7636. The client creates a code_verifier and sends a code_challenge derived from it with the authorization request. This request is the example in the OAuth 2.1 draft, with line wraps for display:
GET /authorize?response_type=code&client_id=s6BhdRkqt3&state=xyz
&redirect_uri=https%3A%2F%2Fclient%2Eexample%2Ecom%2Fcb
&code_challenge=6fdkQaPm51l13DSukcAH3Mdx7_ntecHYd1vi3n0hMZY
&code_challenge_method=S256 HTTP/1.1
Host: server.example.comThe client then sends the authorization code to the token endpoint with grant_type=authorization_code and adds the code_verifier. The server transforms the verifier and denies access if the result differs from the challenge. An attacker who intercepts the code cannot redeem it, because they do not hold the verifier.
RFC 9700 requires PKCE for public clients and recommends it for confidential ones. RFC 7636 says a client that can use the S256 method must use it.
Grants for services and devices
Client credentials. RFC 6749 lets a client request a token with only its own credentials, to access protected resources under its control. The token request carries grant_type=client_credentials, and the client must authenticate. Only confidential clients may use the grant, and the response should not include a refresh token.
Device authorization. RFC 8628 defines this grant for devices that lack a browser or are input constrained. The client starts with a request to the device authorization endpoint. This is the RFC's example:
POST /device_authorization HTTP/1.1
Host: server.example.com
Content-Type: application/x-www-form-urlencoded
client_id=1406020730&scope=example_scopeThe response contains a device_code, a user_code and a verification_uri. The client shows the code and the URI to the user, who visits the URI on a secondary device and enters the code. Meanwhile the client polls the token endpoint with the grant type urn:ietf:params:oauth:grant-type:device_code and the device_code. While the request is pending, the server answers authorization_pending. On slow_down the client must add 5 seconds to its polling interval.
The RFC warns of remote phishing: an attacker starts the flow on their own device and sends the victim the URL and the code. It recommends asking the user to confirm that the device is in their possession.
Refresh tokens
RFC 6749 defines a refresh token as a credential used to obtain access tokens. It is sent only to the authorization server and never to a resource server.
For public clients, RFC 9700 requires one of two protections. The refresh token is cryptographically bound to a client instance, or it rotates: the server issues a new one with every refresh and invalidates the previous one. If an invalidated token is presented, the server revokes the active one.
The implicit and password grants
- Implicit grant (
response_type=token): the authorization server returns the access token in the authorization response. RFC 9700 says such responses are vulnerable to access token leakage and replay, and that clients should use the code grant in its place. - Resource owner password credentials grant: RFC 9700 says it must not be used. It exposes the resource owner's credentials to the client, and it is not designed to work with two-factor authentication.
RFC 9700 is BCP 240, published in January 2025, and it updates RFC 6749. OAuth 2.1 omits both grants. On 24 November 2026 it is an Internet-Draft, draft-ietf-oauth-v2-1-17, dated 31 October 2026. Its header says it obsoletes RFC 6749 if approved.
The grant for each client
- Web app with a server side: RFC 6749 profiles it as a confidential client and says the authorization code grant is optimized for confidential clients. RFC 9700 recommends PKCE for it.
- Single-page app: RFC 10017, published in August 2026, gives three architectures in decreasing order of security: a backend for frontend that keeps tokens away from the browser, a token-mediating backend, and a browser-based OAuth client. A browser-based public client must use PKCE.
- Mobile app: RFC 8252 requires a native app to make the authorization request through an external user agent, primarily the user's browser. A public native client must implement PKCE.
- CLI: GitHub's documentation describes the device flow as a way to authorize users of a headless application such as a CLI tool. RFC 8252 lets a native app that can open a port on the loopback interface receive the redirect at
http://127.0.0.1:{port}/{path}. - Service: client credentials, when the client accesses resources under its own control.
Mistakes to look for
- PKCE with the
plainmethod. RFC 9700 saysS256is the only method that does not expose the verifier in the authorization request. - Redirect URIs matched by pattern. RFC 9700 requires exact string matching, except for port numbers in localhost redirect URIs of native apps.
- A secret shipped inside an app. RFC 8252 says that when an app goes out to multiple users with a secret statically built into it, that secret should not be treated as confidential.
- Access tokens in URL query parameters. RFC 9700 notes that they can end up in the browser history.
Sources
- RFC 6749: The OAuth 2.0 Authorization Framework
- RFC 7636: Proof Key for Code Exchange by OAuth Public Clients
- RFC 8252: OAuth 2.0 for Native Apps
- RFC 8628: OAuth 2.0 Device Authorization Grant
- RFC 9700: Best Current Practice for OAuth 2.0 Security
- RFC 10017: OAuth 2.0 for Browser-Based Applications
- The OAuth 2.1 Authorization Framework (draft-ietf-oauth-v2-1)
- Authorizing OAuth apps
Want a second pair of eyes on yours? We do this work for a living.
More guides

OpenID Connect for engineers: tokens, claims and trust
Authentication · 4 min read
Three parties, two tokens, one discovery document, and the five claims a relying party must check.

What is inside a JWT and how to validate one
Authentication · 4 min read
Header, payload and signature, the checks to run, and the mistakes that let forged tokens in.

Secrets in CI/CD: where they leak and how to stop it
Secrets · 4 min read
Six places a pipeline secret escapes, and the GitHub Actions settings that close each one.