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 OAuthA framework that lets a person give an application limited access to their resources at another service, using tokens instead of sharing their password. OAuth is about access; OpenID Connect adds sign-in. 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.
| Role | In the example | What it decides |
|---|---|---|
| Resource owner | Ava | Whether the printer may read her photos at all. |
| Client | The printer | What access to ask for, and how to use and protect the token it receives. |
| Authorization server | The photo service's sign-in and approval system, auth.photos.example | Who Ava is, whether this client may ask for this access, and which tokens to issue. |
| Resource server | The photo API, api.photos.example | Whether 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 tokenA piece of data issued by a trusted service that a client presents as a credential, for example to call an API or to report a sign-in. Some tokens carry readable claims; others are random strings that only the issuer can interpret.. The photo APIAn application programming interface: a defined way for software to interact with a service. A web API offers endpoints where other programs send HTTP requests. 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 serverIn OAuth, the API that holds protected resources and decides, for each request, whether the presented access token allows it. 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 flowThe main OAuth flow: the browser visits the authorization server, where the person signs in and approves access, then carries an authorization code back to the client, which exchanges it for tokens directly. When the client runs on a server, the tokens never pass through the browser., the flow this series follows first, three of them carry the connection:
| Address | Belongs to | What happens there |
|---|---|---|
| Authorization endpoint | Authorization server | The client sends Ava's browser here to start an authorization. Ava signs in and approves on this server's pages. |
| Redirect URI | Client | The authorization server sends Ava's browser back here with its answer. |
| Token endpoint | Authorization server | The 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/tokenThe 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 JSONA text format for structured information, written as named values inside curly braces. APIs, tokens, and discovery documents all use it. document called authorization server metadata (RFC 8414). It sits at a well-known address built from the server's issuer identifier, the HTTPSHTTP protected by TLS, so traffic is encrypted and checked for changes while it travels. It protects the connection, but does not prove that the site at the other end is honest. URLA web address, such as https://photos.example/api/albums/42?limit=10. It names how to connect (https), the domain, the path to a particular page or resource, and any extra parameters after the question mark. 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 setA JSON document, published at a fixed HTTPS address, that lists an issuer's current public keys so others can verify its signatures. It never contains private keys. 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 ConnectAn identity layer on top of OAuth 2.0 that lets an application sign people in with an account at another service. It adds the ID token, standard claims, and discovery to the OAuth exchange. 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.
Following the messages
Put the roles and the addresses together and the connection becomes five messages. Ava chooses Connect your photos in the printer:
- The printer redirects Ava's browser to the authorization endpoint, with a request saying which client is asking and what access it wants.
- 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.
- The authorization server redirects Ava's browser to the printer's redirect URI, carrying a short-lived authorization code.
- The printer's backend sends that code to the token endpoint in a direct request and receives an access tokenA token that a client presents to an API to use access it has been granted, usually limited in what it allows and how long it lasts. It authorizes API calls; it does not tell the client who signed in. in the response.
- 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.
Try it in the Lab
- Map the OAuth roles and endpoints onto your lab tenantFind each endpoint in your lab tenant's metadata, move the token endpoint and watch a client that reads the metadata follow it, then see which messages the browser carried.