Client ID metadata documents
Every way the printer has become a client so far leaves it with an identifier some authorization server chose and stored. This lesson follows a lighter design for a printer that meets many photo services it has never heard of: the client ID is an address where the printer publishes its own metadata. It covers what the server checks and how it fetches safely, what such a document proves, how to choose between the registration approaches, and the whole discovery path from an API's challenge to 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..
A client ID that is a URL
The printer has met three ways to become a client so far. Its developers registered it by hand at the photo service, it registered itself at a server it discovered in Registering a client dynamically, and it learned to keep that registration current with the management protocolAn agreed set of rules for the messages two systems exchange and what each message means. HTTP, OAuth 2.0, OpenID Connect and SAML are all protocols.. Each of them leaves the printer with a client ID that some authorization server chose and stored.
Now imagine a printer that connects to photo services it has never heard of, chosen by its customers one at a time. Registering by hand is impossible. Registering dynamically works, but every server it visits keeps a new registration, with a client ID and perhaps a secret the printer has to store, and most of those registrations are used once and then forgotten. There is a lighter alternative: let the client ID itself say where the client's metadata lives.
In a client ID metadata document design, the client ID is 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 at that URL the client publishes a JSONA text format for structured information, written as named values inside curly braces. APIs, tokens, and discovery documents all use it. document of its own metadata, using the same field names as dynamic registration. The approach is described in draft-ietf-oauth-client-id-metadata-document, an IETF draft of the 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. working group, not yet an RFC, so its details may still change.
All domains, identifiers, and keys in these examples are fictional. The printing company publishes this document at https://printer.example/oauth/client-metadata.json:
{
"client_id": "https://printer.example/oauth/client-metadata.json",
"client_name": "Photo Printer",
"client_uri": "https://printer.example",
"logo_uri": "https://printer.example/logo.png",
"redirect_uris": ["https://printer.example/oauth/callback"],
"grant_types": ["authorization_code"],
"response_types": ["code"],
"token_endpoint_auth_method": "private_key_jwt",
"jwks_uri": "https://printer.example/oauth/jwks.json",
"scope": "photos.read"
}The printer then starts an authorization request at a server it has never contacted, with that address as its client_id. Nothing was registered in advance. The server reads the address, fetches the document, and treats what it finds as the client's registration, much as it would treat a registration request it had just received.
The identifier has rules of its own, because it is both a name and an address the server will fetch. It must use https and must have a path, so a bare host is not enough, and a path of just / is discouraged. It must not contain a fragment, user information such as user@, or the dot segments . and .., and it should not contain a query. The server compares it as a plain string, so https://printer.example:443/oauth/client-metadata.json is a different client from the one above. A short address that the company can keep for years works best, because changing the URL means becoming a new client everywhere.
Fetching and checking the document
When the request arrives, the photo service fetches the document:
GET /oauth/client-metadata.json HTTP/1.1
Host: printer.example
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Cache-Control: max-age=3600
{
"client_id": "https://printer.example/oauth/client-metadata.json",
"client_name": "Photo Printer",
...
}Only a 200 response counts. Any other status is an error, and the server does not follow redirects, so a document can only be the one at the address the client named. The client_id inside the document must equal that address exactly. If it named another URL, one address would be speaking for a different client, the same mistake Authorization server metadata rules out for issuers.
The redirect URIs come from the document. The server compares the request's redirect_uri exactly with the list it fetched, as it would with a registered client, so an authorization codeA short-lived, single-use value that the authorization server sends back to a client through the browser. The client swaps it for tokens in a direct request to the authorization server; APIs never accept it. can only go to an address the client's own host published. A server may also insist that the redirect URIs share an origin with the client ID or client_uri.
Some values are forbidden. There is no shared secret in this design, because a document anyone can read cannot deliver one: client_secret and client_secret_expires_at must not appear, and neither may a token_endpoint_auth_method based on a shared secret, such as client_secret_basic. A client that can keep a 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. authenticates with private_key_jwt instead, publishing only its public keys through jwks or jwks_uri, and the server then requires a signed client assertion made with one of them. A client that cannot keep a key is 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. and relies on PKCEProof Key for Code Exchange, pronounced pixie: the client creates a secret for each authorization attempt, sends only a hash of it at the start, and proves it holds the secret when redeeming the code, so a stolen authorization code is useless to anyone else. alone.
The server may cache what it fetched, following the response's HTTPThe Hypertext Transfer Protocol, the rules browsers, apps, and servers use to send requests and responses on the web. cache headers within limits of its own, here an hour. It never caches an error or a document that failed its checks, so a fixed mistake takes effect on the next request. When the document changes in ways that matter, such as a new redirect URI, new keys, or wider scopes, the server can treat earlier consent as no longer covering the client and ask again.
A server that supports the design says so in its metadata, with "client_id_metadata_document_supported": true. A client checks that member before sending a URL as its client ID, so it does not send someone to a server that will only show an error.
Fetching an address someone else chose
The client ID arrives in an authorization request that anyone can send, so the server is fetching an address chosen by whoever sent it. Protected resource metadata met the same problem from the client's side, and the same precautions apply here, on the server.
The server must not fetch a client ID, or any address inside the document, that resolves to a special-use address such as a loopback, private, or link-local address. Without that rule, a request naming https://10.0.0.5/admin would make the authorization server send a request into its own network on an attacker's behalf, which is server-side request forgery. The check belongs after name resolution, because a public name can point at a private address, and a network policy that blocks such connections outright is a sound second layer.
It also bounds the work: a short timeout, no redirects, and a size limit, with a response that reaches the limit treated as an error. The draft recommends reading no more than 5 kilobytes, which is plenty for real metadata. Addresses inside the document that the server shows or fetches, such as logo_uri, use only expected schemes such as https, never something like javascript:.
Fetching has a privacy side as well. Each fetch tells the printing company that someone at this photo service is using the printer right now. Caching reduces that, and so does fetching the logo once and serving a copy, rather than having every consent screen load it from the client's host.
What the document proves
A metadata document proves that whoever controls printer.example published these values. It proves nothing about who that is. Anyone who owns a domain can publish a document at https://photo-prints.example/client.json that says "client_name": "Photo Printer" and shows a familiar logo. As with any self-asserted metadata in Client metadata and software statements, the name is whatever its author typed.
What the design does guarantee is useful. The client ID cannot be reused by someone who does not control its host, because the redirect URIs and keys come from that host, so codes for https://printer.example/oauth/client-metadata.json go only to the printing company's callback, and only its key can redeem them. The consent screen should therefore show the client ID's hostname next to any name and logo it fetched, so Ava can see that the request comes from printer.example and not from a lookalike. Where the server could not fetch the document, the hostname is the only identifying information it has.
The printing company
- client_id
- https://printer.example/oauth/client-metadata.json
- client_name
- Photo Printer
- Redirect URI and keys
- from printer.example
- Consent screen shows
- Photo Printer, printer.example
Codes go only to the printing company's callback
A lookalike
- client_id
- https://photo-prints.example/client.json
- client_name
- Photo Printer
- Redirect URI and keys
- from photo-prints.example
- Consent screen shows
- Photo Printer, photo-prints.example
Same name: only the hostname tells it apart
A document proves control of the host that serves it, not who runs it.
Anything beyond domain control is the server's own decision. A photo service might trust any client ID metadata document for low-risk scopes, show a warning for hosts it has never seen, and keep an allowlist of reviewed hosts for sensitive ones. A document can carry a software statement too, as described in Client metadata and software statements, when a party the server trusts has vouched for the software.
Choosing how a client registers
The three approaches differ in who keeps the registration and what each side has to store:
| Approach | Where the registration lives | Fits |
|---|---|---|
| Pre-registration | At the server, entered by its operators. The client stores the ID and credentials it was given. | Known partners, and anything needing a contract or review first |
| Dynamic registration | At the server, created by the client's request. The client stores a client ID, perhaps a secret, and a registration access token for each server. | Software that registers once per server and keeps using it, possibly with a software statement or an initial access token |
| Client ID metadata document | At the client's own address. Every server reads the same document, and the server stores at most a cached copy. | Clients that meet many servers they have no prior relationship with |
That last situation describes the clients of the Model Context Protocol (MCP), which lets AI applications connect to tools and data sources run by other parties. An MCP client is often an assistant that a person points at a server it has never seen. MCP's authorization specification builds on the pieces of this group: the server publishes protected resource metadata as in RFC 9728, the client follows it to authorization server metadata as in RFC 8414, and recent revisions of the specification prefer client ID metadata documents for registration, with dynamic registration as a fallback and pre-registration where a relationship already exists. The flow is then the code flow with PKCE and the resource parameter.
Putting discovery together
Here is the whole path from an unfamiliar API to a token, for a printer that has only the address https://api.photos.example and the trust list its developers configured.
1. The API answers with a challenge. The printer calls the API's own address, its resource identifier, without a token, as in Protected resource metadata:
GET / HTTP/1.1
Host: api.photos.example
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer resource_metadata="https://api.photos.example/.well-known/oauth-protected-resource"2. The printer reads the API's metadata. It fetches the address from the challenge and checks that resource is exactly the API it called:
GET /.well-known/oauth-protected-resource HTTP/1.1
Host: api.photos.example
HTTP/1.1 200 OK
Content-Type: application/json
{
"resource": "https://api.photos.example",
"authorization_servers": ["https://auth.photos.example"],
"scopes_supported": ["photos.read", "photos.write"],
"bearer_methods_supported": ["header"]
}The listed authorization server is on the printer's trust list, so it continues. A server it did not trust would end the attempt here, whatever the document said.
3. The printer reads the authorization server's metadata and checks that issuer is identical to the value it started from:
GET /.well-known/oauth-authorization-server HTTP/1.1
Host: auth.photos.example
HTTP/1.1 200 OK
Content-Type: application/json
{
"issuer": "https://auth.photos.example",
"authorization_endpoint": "https://auth.photos.example/authorize",
"token_endpoint": "https://auth.photos.example/token",
"registration_endpoint": "https://auth.photos.example/register",
"code_challenge_methods_supported": ["S256"],
"token_endpoint_auth_methods_supported": ["private_key_jwt"],
"client_id_metadata_document_supported": true,
"authorization_response_iss_parameter_supported": true
}4. The printer chooses how to register. The server supports client ID metadata documents, so the printer uses its document's URL as its client ID and registers nothing. Had the member been absent, it would have sent a registration request to registration_endpoint instead, and used the client ID that came back.
5. The printer sends the authorization request with PKCE and the resource parameter, so the token works only at the photo API:
https://auth.photos.example/authorize
?response_type=code
&client_id=https%3A%2F%2Fprinter.example%2Foauth%2Fclient-metadata.json
&redirect_uri=https%3A%2F%2Fprinter.example%2Foauth%2Fcallback
&scope=photos.read
&resource=https%3A%2F%2Fapi.photos.example
&state=demo-attempt-12
&code_challenge=qd-75t-gnweZAhIl6REjxxgFnPXGwvqYcxq3vlsaJYQ
&code_challenge_method=S256The photo service fetches and checks the printer's document, confirms that the redirect URI is in it, and shows a consent screen naming Photo Printer from printer.example. Ava approves, and her browser returns to the callback with a code, the printer's state, and iss=https://auth.photos.example, which the printer compares with the issuer it checked in step 3.
6. The printer redeems the code with its verifier, the same resource, and a client assertion signed with the key its document publishes:
POST /token HTTP/1.1
Host: auth.photos.example
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code
&code=demo-code-31
&redirect_uri=https%3A%2F%2Fprinter.example%2Foauth%2Fcallback
&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
&resource=https%3A%2F%2Fapi.photos.example
&client_assertion_type=urn%3Aietf%3Aparams%3Aoauth%3Aclient-assertion-type%3Ajwt-bearer
&client_assertion=eyJhbGciOiJFUzI1NiIsImtpZCI6InByaW50ZXItY2lkLTEifQ...The body is form-encoded, with line breaks for display. The assertion's iss and sub are the client ID URL, and its aud is the issuer, as Secrets and signed assertions described. The server checks its signature with a key from the printer's jwks_uri and returns an access token whose audience is https://api.photos.example.
7. The printer calls the API again, now with the token in the Authorization header, and receives Ava's albums.
Every value the printer used came either from its own configuration, the trust list and its own document, or from a document it fetched and checked before use. The API pointed to its authorization server, the authorization server described itself and named the issuer to expect, and the printer's own address told the server who the printer was, and each document was checked against the address it came from, so none could speak for another party.
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
- Follow an API's 401 to a token, then write and check a client ID metadata documentRun discovery end to end against the sample photo API and your tenant, get a token for that API with PKCE and resource, then write the printer's client ID metadata document and check it against the draft's rules.