Client IDs and registration
Every exchange so far started with the photo service already knowing the printer. That knowledge comes from a registration: a record at the authorization serverIn OAuth, the service that handles a person's sign-in and approval and decides which tokens to issue to a client. It may belong to the same company as the API, but its job is separate. that names one client and sets the rules every later request is checked against.
Introducing the printer
When the printer sent Ava Archer's browser to the photo service so she could connect her photos, the authorizationDeciding whether a requested action is permitted, such as whether a signed-in account may delete a particular photo. Authentication says which account is asking; authorization decides what it can do. server recognized photo-printer in the request. It knew where to send her browser back, and it knew how the printer would prove itself at the token endpointThe authorization server address where clients exchange an authorization code, refresh token, or other grant for tokens, in a direct request rather than through a browser redirect.. None of that happened by accident. Before the printer sent its first request, someone at the printing company introduced it to the photo service.
That introduction is client registration. The photo service runs a developer console, a set of pages where software developers manage their applications. A developer at the printing company signs in, chooses Register an application, and fills in a form: the application's name, its website, the address a person's browser should return to, and the kind of access it needs.
When the form is saved, the authorization server creates a record for the printer and assigns it a client ID:
Client ID: photo-printer
Client type: confidential
Redirect URI: https://printer.example/oauth/callback
Grant types: authorization_code, refresh_token
Scopes it may request: photos.read
Client authentication: client_secret_basicAll domains, identifiers and credentials in these examples are fictional.
The client ID is how the printer names itself in every request. It appears in authorization URLs, so it passes through browsers, history and server logs. That is fine, because a client ID is an identifier, not a credential. Knowing photo-printer lets someone write a request that claims to come from the printer. It does not let them prove that claim. As Public and confidential clients explained, a confidential clientAn OAuth client, typically running on a backend, that can keep a credential such as a client secret or private key protected, and so can authenticate itself to the authorization server. proves its identity with a separate credential, and a public clientAn OAuth client, such as code running in a browser or an app on a phone, that cannot keep a credential secret because the people using it can inspect it. It relies on protections such as PKCE instead of a client secret. has no such proof to offer.
The value is unique only at the authorization server that issued it. photo-printer means something to the photo service. Another service the printer also uses would issue its own client ID, perhaps a random string such as 8f3c21e9-6b4d-4a1f-9e2c-5d07b8a4c613, and keep its own registration. Sent to that other service, photo-printer names nothing at all.
What a registration records
The summary above is more than paperwork. Each line becomes a rule the authorization server applies to every request that names photo-printer.
The client type tells the server whether to expect client authentication. The redirect URI limits where authorization responses may go. The grant types list the ways this client may obtain tokens, so a request from photo-printer using the client credentials grant is refused, even if everything else about it is correct. The scopes limit what the client can receive at all, before any person is asked to approve it. The client authentication line says how the client will prove itself, and the server holds whatever it needs to check that proof. Here, client_secret_basic means the printer sends a secret in the Authorization header of its 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. requests; the next lessons in this group compare it with the other methods.
photo-printer
- Client type
- confidential
- Redirect URI
- https://printer.example/oauth/callback
- Grant types
- authorization_code, refresh_token
- Scopes it may request
- photos.read
- Client authentication
- client_secret_basic
Checked against the registration
- authorization_code, photos.read, registered address
- client_credentials: unauthorized_client
- https://printer.example/other: refused
- photos.write: invalid_scope or dropped
Only the first goes on to consent, policy and the API
A request that falls outside the registration never reaches those decisions.
Registration therefore decides what a client is allowed to attempt. Each request still has its own checks: Ava can refuse consent, the photo service can apply policy, and the 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. can reject an operation. A request that falls outside the registration never reaches those decisions. An unregistered redirect URI or grant type is rejected, because this client was never set up to use it. As Errors and denied access showed, a grant the client may not use comes back as unauthorized_client. A scope outside the registration is either rejected with invalid_scope or dropped from what the server grants, depending on the server, so the client never receives it.
The record also gives the photo service a place to act. It can suspend a client that misbehaves, which stops new authorization requests and token requests from that client. It can list the people who have connected a client, show the client's name in Ava's list of connected applications, and remove its access in one place.
One application, several clients
The printing company does not run just one piece of software. Its website's backend connects to the photo service, and so does its phone app, which lets Ava pick photos for a book on her phone and is registered as photo-printer-app. The company also runs a test copy of the website, where developers try changes before releasing them. Its scheduled job that sends orders to the print lab is a client too, but of a different authorization server: the print lab registered it separately, with its own client ID.
It is tempting to register "the printer" once and share that registration everywhere. That would blur exactly the things registration is meant to keep precise.
The website's backend is a confidential client that can keep a secret. The phone app is a public client that cannot, because every copy installed on a phone carries the same files, and anyone can take a copy apart. Given one shared registration, the photo service could not tell which one was asking, and it could not require client authentication from one without breaking the other. The test website has its own return address on a test domain, which should never be accepted for the real service. And if the phone app's client ID were ever abused, the printing company would want to suspend that client alone, not its website as well.
So each deployment with different credentials, return addresses or permissions gets its own registration and its own client ID. Ava's account might list them under one name, Photo Printer, while the authorization server treats them as separate clients with separate rules. A credential belongs to one registration too: the website's secret proves nothing for photo-printer-app, even though the same company holds both.
A developer filling in a form is the most familiar way to register a client, but it is not the only one. An administrator can create registrations for an organization's own applications, and some services let software register itself through an API, which Registering a client dynamically, in Advanced 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., covers. A newer approach, Client ID Metadata Documents, skips the registration step altogether: the client ID is itself an 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., and the authorization server fetches the client's details from that address the first time it sees the client. It suits software that meets many authorization servers it has never been introduced to.
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
- Read a client registration as a set of rulesMap each line of the printer's registration to a request it allows or refuses, suspend one client without affecting its sibling, and see that a client ID means something only to its issuer.