Beta

Create a tenant

A new tenant starts with its own users, OAuth settings, audit history and logs. You are its first Tenant Admin.

Choosing a flow

Every OAuth grant answers a particular situation. A few questions about whose access it is, how the person can approve it and whether it must continue usually point to one flow, and the older flows that skip those questions are best left alone.

Asking about the situation

Over the last few lessons, the printing application has obtained access in several different ways. It sent Ava's browser to the photo service to read her photos, kept a refresh token for next December's calendar, and authenticated as itself to submit print jobs. A photo frame polled for a token while Ava approved it on her phone, and Lantern's portal presented an assertion from its own identity provider.

Each of those choices followed from the situation, not from a preference for one flow. A few questions about the situation usually lead to the right one.

Whose access is it? Start here, because it separates the grants most clearly. If the client needs access to something that belongs to a person, such as Ava's photos, a person has to authorize it. If the client needs access as itself, as the printer does at the print lab, there is no person to involve, and the client credentials grant fits. Ava can't approve the printer's dealings with the print lab, and nobody needs her to.

Can the person use a browser on this device? When a person authorizes access, the authorization code flow with PKCE is the default. The person signs in and decides at the authorization server, and the result returns to the client that asked. If the device cannot reasonably show a browser or accept typing, like the photo frame, the device authorization grant moves the sign-in and approval to another device.

Has the person's authority already been established elsewhere? Sometimes an organization has authenticated the person and has an arrangement with the authorization server about what that means, as Lantern did. Then an assertion grant can turn the organization's signed statement into an access token without another interactive approval. Without that arrangement, the person authorizes through one of the interactive flows.

Does the access need to continue? This question is separate from the others. A refresh token is not a way to obtain access for the first time. It extends an authorization the client already has, obtained through one of the flows above, so the client can get new access tokens when the person is not present.

Where does the client run? This does not usually change the grant, but it changes how the client uses it. A confidential client authenticates at the token endpoint. A public client cannot, so it relies on protections such as PKCE, and it cannot use the client credentials grant at all. An application running in the browser may be better served by a backend that acts as its confidential client. The Application architectures lessons, starting with Server-rendered web applications, look at those designs one at a time.

Situations side by side

Each row of this table pairs a situation with the grant that fits it. The first five are the grants this series has covered; the last two are later extensions for situations the others don't handle well.

SituationFlow or grant
A person authorizes access in a browser on the same deviceAuthorization code flow with PKCE
A person authorizes access for a device with no practical browser or keyboardDevice authorization grant
A client accesses a service as itself, with no person involvedClient credentials grant
A trusted issuer has already vouched for the person, under an arrangement set up in advanceJWT or SAML assertion grant
A client needs new access tokens for an authorization it already holdsRefresh token grant
The client starts the request, and a known person approves it on their own phone, with no code to typeClient-Initiated Backchannel Authentication (CIBA), from OpenID Connect
A service that received a token for a person needs a token for another service, still on that person's behalfToken exchange

Real products often combine rows. The printer uses the authorization code flow to connect Ava's account, the refresh token grant to keep the connection working, and client credentials for its own dealings with the print lab. Each piece is chosen for the access it provides.

The last two rows go beyond the grants in this series. A print shop kiosk that knows Ava and asks the photo service to send an approval request straight to her phone, without a code to type, uses CIBA, which Separating the consumption and authentication devices introduces. A photo API that must fetch Ava's image files from a separate storage service, still on her behalf, uses token exchange, which The problem token exchange solves introduces.

Start with whose access it is, then ask how the person can authorize it. Refresh tokens extend an authorization. They do not start one.

Flows to avoid

You'll still meet two older grants in existing integrations and older tutorials.

The implicit grant returned an access token directly in the browser redirect, with no code exchange. It was designed for browser applications at a time when they had few alternatives. Tokens placed in redirect addresses can leak through browser history, server logs and the Referer header a browser sends to the next site, and nothing binds them to the client that asked. Browser applications now use the authorization code flow with PKCE instead.

The resource owner password credentials grant let a client collect a person's username and password and send them to the token endpoint. That is the password sharing OAuth set out to replace. It also prevents the authorization server from using stronger sign-in methods, because the client only knows how to handle a password. Current security guidance says it must not be used.

Neither should be chosen for a new integration. In History, legacy, and migration, The implicit grant and The password grant explain how they worked, and Migrating older integrations how to move existing integrations away from them.

Choosing a grant is only the first decision. Whichever flow a client uses, the authorization server checks each request against the client's registration, and a confidential client also proves who it is.

Check your understanding

Try these questions before moving on. If an answer isn't right, use the feedback and try again.

A smart TV app needs to show Ava's photos. The TV has only a remote control. Which flow fits? 1 of 3

Choose one answer.

A new integration wants long-lived access to a person's photos. Which statement is correct? 2 of 3

Choose one answer.

An older tutorial shows a browser photo editor getting Ava's token straight from the redirect, with no code exchange. What should a new editor use? 3 of 3

Choose one answer.

Try it in the Lab

We value your privacy

We use cookies and similar technologies to enhance your browsing experience, and analytics to understand our traffic. By clicking "Allow all", you consent to optional analytics. Cookie Policy

Learn identity