Redirect URIs and client metadata
A registration holds two kinds of information. Some of it decides where 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. will send codes; some of it describes the client to the people asked to approve it. Both come from the client's developer, but only the first is enforced.
Registering return addresses
The Redirects and authorization codes lesson explained why 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 compares a requested redirect URI with the registered value exactly. Registration is where those values come from.
A client can register more than one. The printer's website might accept returns at two paths, one for connecting a photo account and one for adding a second account later:
https://printer.example/oauth/callback
https://printer.example/oauth/add-account/callbackAll domains, identifiers, and credentials in these examples are fictional.
Each authorization request names the one it wants, and the server accepts only an exact match with an entry in the list. Registering a pattern such as https://*.printer.example/ instead would let any address on any subdomain receive codes, including a forgotten marketing page or a subdomain someone else later controls. A list of specific addresses keeps the set of possible destinations small and known.
Web clients register HTTPS addresses on domains they control. The printer's test website, at https://test.printer.example/oauth/callback, belongs in the test client's registration, not in the production list. If it were added to the production client, a mistake on the test site could leak codes for real accounts.
Return addresses for installed apps
The printer's phone app, photo-printer-app, and its desktop app have no website of their own to return to. Each still needs the browser to hand the authorization response back to the app, and installed applications have three common ways to receive it. The first two suit phone apps; the third is for desktop applications.
A claimed HTTPS address is 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. that the operating system has verified belongs to the app, such as https://app.printer.example/oauth/callback. When the browser opens it, the system passes it to the app. Because the printing company had to prove control of the domain, another app cannot claim the same address. This is the strongest of the three where the platform supports it.
A private-use URI scheme is a custom scheme the app registers with the operating system, written as a reversed domain name the developer controls, such as example.printer:/oauth/callback. It is widely supported, but nothing stops another app on the same device from registering the same scheme. That is one reason installed apps must use 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.: a code delivered to the wrong app is useless without the verifier, which never left the app that started the request.
A loopback address suits desktop applications and command-line tools, such as the printer's desktop app. The application listens briefly on the local machine and registers an address such as http://127.0.0.1/oauth/callback. The operating system chooses a free port each time, so the authorization server lets the port vary for loopback addresses while still matching the rest exactly: the app can ask for http://127.0.0.1:51004/oauth/callback today and a different port tomorrow. Plain HTTP is acceptable here because the response never leaves the machine. A phone app uses one of the first two instead. They are how mobile platforms hand a response to an app, and an app listening on a local port may be suspended while the browser is in front.
The address names the literal loopback IP, 127.0.0.1 for IPv4 or [::1] for IPv6, rather than localhost. Current guidance marks localhost as not recommended. It is a name the machine must resolve, and a changed hosts file or resolver setting can point it somewhere other than the local machine. An app that opens its listener by name can end up listening on a network interface other than loopback, and client-side firewalls are more likely to get in the way. Where the app cannot be sure whether IPv4 or IPv6 will be available, it can register and try both.
Phone app
https://app.printer.example/oauth/callback
- Another app on the device
- Cannot claim the same address
The strongest of the three
Phone app
example.printer:/oauth/callback
- Another app on the device
- Can register the same scheme
Useless without the verifier
Desktop app
http://127.0.0.1:51004/oauth/callback
- The port
- May vary
- localhost in its place
- Refused
The response never leaves the machine
Describing the client
Registrations also hold client metadata: descriptive values the authorization server can show to people. Expressed with the standard field names that registration APIs use, the printer's might be:
{
"client_name": "Photo Printer",
"client_uri": "https://printer.example",
"logo_uri": "https://printer.example/logo.png",
"policy_uri": "https://printer.example/privacy",
"tos_uri": "https://printer.example/terms",
"contacts": ["[email protected]"]
}The consent screen uses these values. When Ava was asked whether to let the printer read her photos, the name, logo and links on that screen came from this record. They help her recognize the application and find its privacy policy before she decides.
They are also exactly what an impostor would like to control. Anyone who can register a client can type "Photo Printer" into the name field and upload a familiar logo. The authorization server cannot simply trust what a developer wrote about their own application.
Careful services treat descriptive metadata as a claim. They may verify that the client controls the domain in client_uri, check that links point to the same site, review applications before they can reach many users, or show unverified clients with a clear warning. Where a consent screen shows the domain the browser will return to, that domain is often a better clue than the name. The name is free text. The return address is enforced.
Settings that limit requests
Alongside the description, a registration holds technical settings that narrow what the client may do. The most common, again with their standard names:
{
"grant_types": ["authorization_code", "refresh_token"],
"response_types": ["code"],
"token_endpoint_auth_method": "client_secret_basic",
"scope": "photos.read"
}Each one closes off requests the client has no reason to make. A client registered only for 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. cannot use client credentials. A client limited to photos.read cannot receive photos.delete, however its request is written: the server either rejects the request with invalid_scope or leaves that scope out of what it grants. A client registered for one authenticationChecking evidence that someone, or some application, controls an account, such as a password or a passkey. It establishes which account is being used, not what that account may do. method cannot switch to another 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.. Client authentication methods looks at those methods.
These limits work best when they are as narrow as the client actually needs. A registration that allows every grant and every scope gives an attacker who obtains the client's credentials, or who controls one of its return addresses, every capability at once. A registration that matches the client's real behavior turns many mistakes and attacks into ordinary rejections.
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 return addresses and see what consent showsRegister exact return addresses, see unsafe ones refused, keep test and production apart, see that a client's name, logo and links are its own claims, and narrow a client until wrong requests fail.