Flow diagram of the OAuth 2.0 authorization code flow, left to right: the user logs in to your app, your app redirects to the OAuth provider, the user consents there, the provider sends an auth code to your app's callback, and the callback trades the code for a token at the token endpoint, then uses the token to get the profile from the resource server.
Diagram source. Edit it live in the browser
title OAuth 2.0 Authorization Flow

type actor User

User -> Your App: log in
Your App -> OAuth Provider: redirect
User -> OAuth Provider: consent
OAuth Provider -> App Callback: auth code
App Callback <-> Token Endpoint: code for token
App Callback <-> Resource Server: get profile

What this diagram shows

OAuth is confusing because half of it happens as browser redirects you never see in your network tab. Drawn out, it's two separate trips to the provider: one through the browser to get a code, and one server-to-server to swap that code for a token.

"Your App" and "App Callback" are the same application: the route that starts the login, and the route the provider sends the user back to. They're drawn as two boxes so the picture reads left to right. The two-way arrows on the right are server-to-server requests and their responses.

Google, GitHub, Microsoft: same flow. The provider box just changes its label.

Step-by-step flow breakdown

1
User starts the loginThe user clicks "Log in with Google" (or any provider) in your app.
2
Redirect to the providerYour app redirects the browser to the provider's authorize endpoint, with its client ID, the scopes it wants, a state value and the callback URL.
3
User signs in and consentsThe user signs in at the provider, not in your app, and approves the requested permissions.
4
Auth code sent to your callbackThe provider redirects the browser back to your callback URL with a short-lived authorization code. Your app checks that state matches what it sent.
5
Code exchanged for a tokenYour backend sends the code to the provider's token endpoint and gets an access token back. This call is server-to-server; it never goes through the browser.
6
Profile fetchedYour app calls the resource server with the access token, gets the user's profile, and signs the user in with its own session.

When to use this flow diagram

Common variations

PKCE for public clients

Add Your App -> Your App: generate code verifier before the redirect. The redirect carries the hashed code_challenge; the code exchange carries the original code_verifier. RFC 9700 makes PKCE mandatory for public clients such as single-page and mobile apps, and recommends it for everyone else. The OAuth 2.0 sequence diagram shows it call by call.

Refresh tokens

Add App Callback <-> Token Endpoint: refresh token for new access token for when the access token expires. It's the same endpoint as the code exchange, called with a different grant.

Scopes

Put the scopes on the redirect label: Your App -> OAuth Provider: redirect (scope=email profile).

Related flow diagram examples

Frequently asked questions

What does an OAuth flow diagram show?

The authorization code flow end to end: redirect, consent, code, token, profile. Every hop, including the two that happen as browser redirects.

Does this work for any OAuth provider?

Yes. Any OAuth 2.0 provider follows this shape. Rename the provider box and you're done.

Can I use this template for free?

Yes. Open it, edit it, export PNG or SVG. No account.

Sketch your own flow in minutes

Type your steps and services, get a live flow diagram. Export PNG or SVG. Free.

Open Editor Free →