Registering a client dynamically
A developer console works for a client that knows its 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. servers in advance and needs one registration. This lesson follows the printer into the cases where it doesn't: an 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. discovered a moment ago, a phone app that wants a credential for each installation, and review sites that come and go every day. It shows how a registration becomes an HTTPThe Hypertext Transfer Protocol, the rules browsers, apps, and servers use to send requests and responses on the web. request, what open and protected registration each allow, and what a per-installation credential does and does not prove.
When a form is not enough
The printer became photo-printer when a developer at the printing company filled in a form in the photo service's developer console. Client IDs and registration noted that a form is not the only way to create a registration, and that some services let software register itself through an 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..
A form suits a client that knows in advance which authorization servers it will use. The printer now follows APIs to authorization servers it has never met, and no developer can fill in a form for a server that was discovered a moment ago.
Discovery is one reason to register in code. There are two others closer to home.
The printer's phone app has a single client ID, photo-printer-app, shared by every installation. The photo service cannot tell one phone's requests from another's, cannot give any installation a credential of its own, and cannot switch off one misbehaving copy without switching off all of them.
The printing company also creates a temporary copy of its test website for each change under review, at addresses such as https://review-482.test.printer.example. Each copy needs its own client with its own redirect URI for a few days, and nobody wants to visit a console several times a day to create and delete them.
The OAuth 2.0 Dynamic Client Registration Protocol, published as RFC 7591, turns registration into an HTTP request. The authorization server offers a registration endpoint, and a client finds its address in the server's metadata as registration_endpoint. For the photo service it is https://auth.photos.example/register.
Sending a registration request
All domains, identifiers, keys, and tokens in these examples are fictional. When the phone app starts for the first time, the installation generates a key pairA private key and a public key generated together and mathematically linked. The private key creates signatures and the public key checks them, but the private key cannot practically be worked out from the public one. in the phone's secure hardware, the chip that phones provide for keys an app can use but never read out, and registers itself:
POST /register HTTP/1.1
Host: auth.photos.example
Content-Type: application/json
Accept: application/json
{
"client_name": "Photo Printer",
"redirect_uris": ["https://app.printer.example/oauth/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"],
"token_endpoint_auth_method": "private_key_jwt",
"jwks": {
"keys": [
{ "kty": "EC", "crv": "P-256", "kid": "install-key-1", "x": "...", "y": "..." }
]
},
"scope": "photos.read"
}The key values are shortened here. Unlike a token request, the body is JSONA text format for structured information, written as named values inside curly braces. APIs, tokens, and discovery documents all use it., and its members are the client metadata fields from Redirect URIs and client metadata. The installation describes itself the way a developer would in a console form: its name, its return address, the grants it will use, and how it will authenticate. An app on a phone cannot publish a 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. at a web addressA 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., so it sends its public keyThe half of a key pair that can be shared freely. It checks signatures made with the matching private key and can encrypt data that only that private key can decrypt. by value in jwks instead of registering a jwks_uri. The private keyThe half of a key pair that its owner keeps to themselves and uses to create signatures or decrypt data. Anyone who obtains it can act as its owner. never leaves the phone's hardware.
If the photo service accepts the request, it answers with 201 Created and a JSON body that contains a new client ID for this installation, app-7c41e2b9, along with the metadata it registered. From then on, this installation sends client_id=app-7c41e2b9 in its authorization requests and signs client assertions with its own key 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..
Open and protected registration
The request above carried no credential at all. That is open registration: anyone who can reach the endpoint can create a client. RFC 7591 recommends that registration endpoints accept requests without a credential, to make open registration possible, and lets servers limit how many they accept.
Open registration has a cost the photo service has to plan for. "Anyone" includes an attacker, who can register a client called Photo Printer, with the printing company's logo and a redirect URI on their own site. The server must treat everything in an open registration as the registrant's own claim. It can label dynamically registered clients on its consent screens, warn about clients that are new or that few people have approved, and limit what such clients may request. Current security guidance describes attackers using dynamic registration in exactly this way, to obtain a legitimate-looking client for phishingTricking someone, usually with a message and a look-alike sign-in page, into handing over the evidence that opens their account, such as a password or a one-time code. or for a mix-up attack.
Protected registration requires an initial access token: an OAuth access token, usually sent as a bearer token, that authorizes calls to the registration endpoint. How it is issued is left to the service. A common pattern is a developer console that issues one to a developer, which ties every client registered with it back to that developer. The printing company's deployment pipeline holds one in its secrets store and uses it to register each review site:
POST /register HTTP/1.1
Host: auth.photos.example
Authorization: Bearer demo-initial-access-token-5
Content-Type: application/json
Accept: application/json
{
"client_name": "Photo Printer review 482",
"redirect_uris": ["https://review-482.test.printer.example/oauth/callback"],
"grant_types": ["authorization_code", "refresh_token"],
"token_endpoint_auth_method": "client_secret_basic",
"scope": "photos.read"
}The photo service now knows who is asking, and it can apply rules attached to that token, for example that its clients may use only redirect URIs under test.printer.example and may connect only test accounts. If the token leaks, revoking it stops new registrations made with it. The clients it already created are separate records, which the photo service can review on their own.
Phone app installation
- Credential
- none
- client_name
- Photo Printer
- Redirect URI
- app.printer.example
- Server knows
- one installation holds the key
Its own client ID, app-7c41e2b9
Attacker's copy
- Credential
- none
- client_name
- Photo Printer
- Redirect URI
- the attacker's own site
- Server knows
- only the claim
The name proves nothing: consent warns
Review site 482
- Credential
- initial access token
- client_name
- Photo Printer review 482
- Redirect URI
- review-482.test.printer.example
- Server knows
- the pipeline holds the token
The token's rules apply
A client credential proves continuity with one registration, not which software made it.
One client per installation
Back on the phone, per-installation registration changes what the photo service can see and do. Each installation has its own client ID and its own key. A refresh token issued to app-7c41e2b9 is useless to any other installation, because the token endpoint expects a client assertion signed with that installation's private key. If one phone is lost or one copy misbehaves, the photo service can disable that client and leave every other installation working.
Guidance for native apps classifies them as public clients, with one exception: an app that uses a mechanism such as dynamic registration to give each installation its own credential. Be precise about what that credential proves, though. A valid client assertion for app-7c41e2b9 shows that the request comes from whoever holds the private key registered for that client, and because the key never leaves the phone's secure hardware, that means the installation that registered. It does not show that the installation is a genuine copy of Photo Printer. Anyone can send the same registration request from a modified app or a short script and receive a client ID and credential of their own. The credential proves continuity with one registration, not which software made it.
So the photo service still treats the app's identity with the caution it gives a public client. It asks for Ava's approval when a new installation first connects, even if she approved Photo Printer on another phone, and it does not let a name or logo stand in for proof. It relies on exact redirect URI matching and still expects PKCE. Evidence about the software itself has to come from somewhere else, such as platform attestation: a signed statement from the phone's platform that an unmodified copy of a particular app is running on a genuine device.
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
- Register a review-site client through the registration APIAct as the printer's deployment pipeline: turn on Protected registration, register a review-site client with an initial access token, sign Ava in to it, then compare Open registration.