OAuth 2.0 Grant Types Reference

All OAuth 2.0 and PKCE grant types with flows described and security notes.

Reference for OAuth 2.0 grant types — authorization code, PKCE, client credentials, refresh token, device, implicit and password — each with its step-by-step flow, spec and security guidance under OAuth 2.1.

Which OAuth grant type should I use?

For apps that redirect a user, use Authorization Code with PKCE — it now suits both confidential and public clients. For machine-to-machine calls use Client Credentials, and for input-constrained devices like TVs use the Device Authorization grant. Use Refresh Token to renew access without re-prompting.

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.