Pick the right OAuth 2.0 flow for your client
OAuth 2.0 defines several grant types — each a different way for a client to
obtain an access token. The right one depends on whether a user is present,
whether the client can keep a secret, and what kind of device runs it. This
reference lists each grant with its grant_type value, intended use case, the
tokens it issues and its current status under OAuth 2.1.
How it works
Most user-facing flows split into a front channel (the browser redirect where the user authenticates) and a back channel (a server-to-server token exchange). The Authorization Code flow returns a short-lived code on the front channel, which the client swaps for tokens on the back channel — so the token never travels through the URL. PKCE strengthens this by binding the code to the original requester.
1. App -> /authorize?response_type=code&code_challenge=... (front channel)
2. User logs in, consents
3. AS -> redirect_uri?code=AUTH_CODE
4. App -> /token code=AUTH_CODE&code_verifier=... (back channel)
5. AS -> { access_token, refresh_token, id_token }
Machine-to-machine calls skip the user entirely with Client Credentials, and input-limited hardware uses the Device Authorization flow with polling.
Tips and notes
- Default to Authorization Code with PKCE for any flow that signs in a user.
- Use Client Credentials only for trusted backend services, never from a browser where the secret would leak.
- Treat refresh tokens as sensitive: rotate them for public clients and detect reuse to limit damage from theft.
- Do not build new integrations on Implicit or Password grants — both are removed in OAuth 2.1.