Beta

Create a tenant

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

Roles and endpoints

Four roles share the work of connecting Ava's photos to the printer, and they talk to each other at a handful of addresses. Knowing which role owns which decision, and which address belongs to whom, is what lets you follow the exchange message by message.

The participants

Giving another application limited access named the four OAuth roles in the photo book example. Following the connection in detail means being precise about which decision belongs to each of them, because each later check is one role protecting its own decision.

The four OAuth roles, and the decision each makes when Ava connects the printer
RoleIn the exampleWhat it decides
Resource ownerAvaWhether the printer may read her photos at all.
ClientThe printerWhat access to ask for, and how to use and protect the token it receives.
Authorization serverThe photo service's sign-in and approval system, auth.photos.exampleWho Ava is, whether this client may ask for this access, and which tokens to issue.
Resource serverThe photo API, api.photos.exampleWhether each request, with its token, may have the photos it asks for.

Read the table by its last column. Ava decides once, when she approves. The authorization server decides when it issues a token. The photo API decides again on every single request, because only it sees which album a request names. None of them can make another's decision for it.

These are roles, not a requirement for four separate machines or companies. The photo service runs both the authorization server and the resource server here, on two host names; it could just as well serve both from one. A company might instead use a separate identity platform as its authorization server and run only the API itself.

The word client can be misleading at first. In OAuth it means the application seeking access, here the printer. The printer's backend, the part of the application that runs on the printing company's own servers rather than in Ava's browser, can be the OAuth client even though it is itself a server handling requests from browsers. Ava's browser is not a role at all. It carries some messages between the others, as the last section shows.

The endpoints

The roles communicate through endpoints: addresses that receive requests for one particular purpose. In the authorization code flow, the flow this series follows first, three of them carry the connection:

The three addresses of the authorization code flow and who owns each
AddressBelongs toWhat happens there
Authorization endpointAuthorization serverThe client sends Ava's browser here to start an authorization. Ava signs in and approves on this server's pages.
Redirect URIClientThe authorization server sends Ava's browser back here with its answer.
Token endpointAuthorization serverThe client sends a request here, directly, to exchange what the browser brought back for tokens.

For the fictional services, those addresses might look like this:

Authorization endpoint:
https://auth.photos.example/authorize

Client redirect URI:
https://printer.example/oauth/callback

Token endpoint:
https://auth.photos.example/token

The path names are not required OAuth spellings. One server uses /authorize, another /oauth2/v1/auth, and an administrator can move them. What stays fixed is each endpoint's responsibility, and which role it belongs to: two of the three live at the authorization server, while the redirect URI lives at the printer and is registered with the authorization server ahead of time, so the server knows where it may send Ava's browser back.

Because the spellings vary, a client should not guess them. Many authorization servers publish their endpoint addresses, and what they support, in a JSON document called authorization server metadata (RFC 8414). It sits at a well-known address built from the server's issuer identifier, the HTTPS URL that names it. For an issuer of https://auth.photos.example, the document is at https://auth.photos.example/.well-known/oauth-authorization-server:

{
  "issuer": "https://auth.photos.example",
  "authorization_endpoint": "https://auth.photos.example/authorize",
  "token_endpoint": "https://auth.photos.example/token",
  "jwks_uri": "https://auth.photos.example/jwks"
}

The jwks_uri is the published key set from JWKs, key sets, and key IDs, where the photo API finds the keys that check the server's signed tokens. The redirect URI is missing on purpose: it belongs to the printer, and lives in the printer's registration, not in the server's own description. Servers that also provide OpenID Connect publish an equivalent document at /.well-known/openid-configuration.

Either document repeats the issuer in its issuer field, and the printer must find exactly the value it started from, character for character, before trusting any address the document lists. A document that names a different issuer, even one on the expected host, is not the server the printer meant to use. Authorization server metadata reads these documents in detail.

The authorization and token endpoints belong to the authorization server. The redirect URI belongs to the client.

Following the messages

Put the roles and the addresses together and the connection becomes five messages. Ava chooses Connect your photos in the printer:

  1. The printer redirects Ava's browser to the authorization endpoint, with a request saying which client is asking and what access it wants.
  2. Ava signs in on the photo service's own page and approves the request. The printer is not involved, so it never sees her password.
  3. The authorization server redirects Ava's browser to the printer's redirect URI, carrying a short-lived authorization code.
  4. The printer's backend sends that code to the token endpoint in a direct request and receives an access token in the response.
  5. The printer calls the photo API with the access token, and the API decides whether to return the album.

Messages 1 and 3 travel through Ava's browser. That is the front channel from How applications communicate: whoever controls the browser can read or change what passes through it. Message 4 is a back channel request from the printer straight to the authorization server, and message 5 goes straight from the printer to the API.

That split explains why the code exists at all. The authorization code is an intermediate credential: it is all the front channel carries, it is short-lived, and on its own it is not the access token. The printer still has to present it at the token endpoint, away from the browser, before any token is issued. The code never reaches the photo API, and the access token never travels through Ava's browser.

This outline is the authorization code flow, and the lessons on that flow go through each message's fields. Other grants use different exchanges, and some involve no browser or person at all, such as the printer sending orders to its print lab on its own behalf. The roles and the token endpoint stay; the browser journey is what changes.

Check your understanding

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

Ava approves the printer, and her browser arrives at the printer's redirect URI carrying an authorization code. What does the printer do with the code next? 1 of 3

Choose one answer.

The printer's developer reads the photo service's metadata document and finds the authorization and token endpoints, but not the printer's redirect URI. Why is it missing? 2 of 3

Choose one answer.

The printer starts from the issuer https://auth.photos.example, but the metadata document it fetches says its issuer is https://login.photos.example. What should it 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