Pick the correct OAuth 2.0 grant
A grant type is the path an OAuth client takes to obtain an access token. The right one depends on what the client is: a web app that can redirect a user, a single-page or mobile app that cannot keep a secret, a backend service acting on its own behalf, or a constrained device like a TV. This tool describes each grant with its step-by-step flow and the security notes that matter, flagging which grants OAuth 2.1 keeps and which it removes.
How it works
In the redirect-based grants, the client sends the user to the authorization
server’s /authorize endpoint and, after consent, receives a short-lived
authorization code. It then exchanges that code at the /token endpoint for an
access token (and often a refresh token). The state parameter guards against
CSRF, and PKCE binds the code to a per-request code_verifier so an intercepted
code is useless. The client_credentials grant skips the user entirely: the
client authenticates with its own credentials to get a token for its own
resources. The device_code grant decouples the device from the browser — the
user approves on a phone while the device polls /token. The legacy implicit
and password grants are described for recognition only; both are removed in
OAuth 2.1.
Tips and notes
Default to Authorization Code with PKCE for any user-facing client and enable
refresh-token rotation with reuse detection so a stolen refresh token can be
revoked across its whole family. For browser-only apps, consider a
backend-for-frontend (BFF) that keeps tokens server-side rather than in
JavaScript. Always validate state, use S256 (never plain) for PKCE, and scope
tokens as narrowly as the task allows. Treat anything that puts a long-lived
token in the browser URL as a red flag.