Beta

Create a tenant

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

The problem OAuth solves

Ava wants a printing application to make a book from one of her photo albums. The printer needs to read those photos, and the obvious shortcut, handing it her password, gives it far more than the job needs. OAuth gives the printer access of its own instead.

Connecting two services

Giving another application limited access introduced the situation this series follows. Ava keeps her photos with an online photo service, and she wants a separate printing application, the printer, to turn her album "Summer trip" into a photo book. Before following OAuth's answer message by message, it helps to look closely at the problem itself, because every part of the answer exists to fix one piece of it.

Ava could download the photos herself and upload them to the printer. That works once, but she would rather connect the two services, so the printer can show her albums and fetch the photos she picks, and fetch them again if she reorders the book next year. So the printer needs some way to make requests to the photo service on Ava's behalf.

The oldest answer was to ask Ava for her photo account's email address and password, store them, and sign in as her whenever it needed something. Many early integrations worked exactly that way. Look at what that gives the printer and what it costs Ava:

  • Everything Ava can do. Her password lets the printer delete albums, change her settings, read photos she never meant to print, and do anything else her account allows. Nothing limits it to reading one album.
  • No separate way to stop it. If Ava wants the printer to stop, the only reliable step is changing her password, which also cuts off every other application she gave it to and means typing the new one everywhere she signs in.
  • Another copy to protect. The printer now stores Ava's password. If the printer is broken into, her photo account goes with it.
  • No way to tell who acted. When the printer signs in with Ava's password, the photo service sees Ava signing in. It cannot tell her own requests from the printer's, so its records cannot say which one deleted an album.

The sign-in methods from Authentication methods and MFA make the shortcut worse. If Ava's account asks for a one-time code or a passkey, the printer cannot complete her sign-in at all. A passkey from Security keys, passkeys, and biometrics only works for the photo service's own site, which is the point of it. And an application that asks people to type their password for one service into another teaches exactly the habit phishing depends on.

What Ava needs is a way to authorize one particular application to do one particular kind of work, without telling it her password, and to take that back without changing anything else.

Delegated access

This is the delegated access problem from Fundamentals: Ava wants the printer to act with some of her authority, not all of it. OAuth 2.0 is the framework most services use to arrange that. In the flow this series studies first, the printer sends Ava's browser to the photo service, where she signs in on the photo service's own page and approves the request. The photo service then issues the printer an access token, and the printer presents that token, not Ava's password, each time it asks the photo API for photos.

Here is what such a request looks like. The printer asks the photo API for album 4420 and puts the token in the Authorization request header, after the word Bearer:

GET /albums/4420 HTTP/1.1
Host: api.photos.example
Authorization: Bearer mF_9.B5f-4.1JqM

HTTP/1.1 200 OK
Content-Type: application/json

{"id": "4420", "title": "Summer trip", "photos": ["9011", "9012"]}

The token value here is a short placeholder; real tokens are much longer. The photo API answers because it accepts the token, not because it saw Ava's password. Every piece of the problem above now has an answer:

  • The token carries the access the photo service granted, for example permission to read photos, so it can be far narrower than Ava's account.
  • The token belongs to the printer's connection alone. Ava can end that connection from her account at the photo service without changing her password, and the service can also let the token expire after a set time.
  • The printer stores a token, not Ava's password, so a break-in at the printer exposes the printer's access, not her account.
  • The photo service issued the token to the printer, so its records can say the printer made a request on Ava's behalf.

When Ava disconnects the printer, the photo service stops honoring the token, and the same request is refused. The WWW-Authenticate response header says why, using the error code invalid_token:

HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer error="invalid_token"

The token is still a credential, so it needs protecting. Most access tokens are bearer tokens, as Giving another application limited access explained: whoever holds a copy can use the access it represents until it expires or the service stops honoring it. OAuth makes the printer's access smaller and separable; it does not make a leaked token harmless.

How small the access is depends on the photo service. One service might let Ava grant access to the single album "Summer trip". Another might offer only permission to read her whole library. Both use OAuth, but Ava would be granting very different authority, and the photo API has to enforce whichever one it offers on every request. Using OAuth does not by itself mean the printer can see only the photos Ava picked.

What the printer holds

Read photos
Granted by the photo service
Ava's password
Never seen
Which albums
Up to the photo service
Ending it
Ava disconnects the printer
Who signed in
Not established

Whoever holds a copy can use the access it represents.

What the printer holds after Ava approves it: access of its own, limited by the photo service, that ends without touching her password. It still has no sign-in result.

Access and sign-in

Ava signs in to the photo service while she approves the connection, so the photo service knows whose account is involved. The printer does not learn that in any standard way. It holds an access token meant for the photo API, and an access token answers "may this request read these photos?", not "who is using the printer right now?".

That matters if the printer also wants a "Sign in with your photo account" button for its own customer accounts. Treating "I received an access token" as "Ava signed in to me" would be a mistake: a token issued to some other application, presented to the printer, says nothing about who is in front of it. The printer needs a result made for it, about a sign-in, which an access token is not.

OpenID Connect adds that authentication layer on top of OAuth 2.0, with an ID token addressed to the printer itself, as Connecting OAuth and OpenID Connect outlined. It comes after the OAuth exchange, in From delegated access to sign-in. Until then the task stays specific: the printer reads the photos Ava allows, and never collects her photo account's password.

Check your understanding

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

Ava wants the printer to make a book from her album "Summer trip". Instead of collecting her password, what does OAuth have the photo service give the printer? 1 of 3

Choose one answer.

The printer holds an access token for Ava's photos and wants to sign her in to a printer account of its own. Is the token evidence of who is using the printer? 2 of 3

Choose one answer.

Years ago Ava typed her photo password into an old album app, which still signs in as her. She wants it to stop. Compared with disconnecting the printer, what must she do? 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