Using the request URI and handling failures
The printer holds a request URI that works for the next 90 seconds. It now sends Ava's browser to the photo service with nothing but that reference and its client ID, and the photo service has to turn the reference back into a request, refuse copies and strangers, and report failures in the right place.
Sending the browser
All domains, codes and identifiers in these examples are fictional. With its parameters on separate lines, the address the printer sends Ava's browser to is:
https://auth.photos.example/authorize
?client_id=photo-printer
&request_uri=urn%3Aietf%3Aparams%3Aoauth%3Arequest_uri%3Ademo-pushed-request-7Compare it with the request in The authorization request. There is no scope, no return address, no state and no 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. challenge. All of them are stored at the photo service, where the push left them. The request URI is percent-encoded because it is a value inside another 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..
client_id is still required. It names the client whose request this is, and the service will check that it matches the client the reference was issued to. Anyone looking at the address bar can see that the printer wants to connect, but nothing there says what it asked for, and there is nothing to edit except a reference that only means something to the photo service.
What the server does with it
When Ava's browser arrives, the photo service turns the reference back into a request:
- It looks up the stored request. An unknown reference is rejected.
- It checks that the reference has not expired and has not already been used.
- It checks that the
client_idin the address is the client that pushed the request. - It processes the stored parameters as an 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. request.
The last step can be shorter than usual. The service validated the request when it was pushed, and it may skip those checks now if it can tell that this is a pushed request and that nothing has changed since that would alter the result. Something can change in 90 seconds. If the printer's registration was suspended, or its return address removed, between the push and Ava's visit, the service checks again and refuses.
Then the familiar part begins. Ava signs in if she needs to, and the consent screen, built from the stored request, asks whether Photo Printer may view her photos. When she approves, the response returns through her browser exactly as before:
https://printer.example/oauth/callback
?code=demo-code-7
&state=demo-attempt-7
&iss=https%3A%2F%2Fauth.photos.exampleThe printer checks state and iss against its pending attempt and exchanges the code with its verifier and client 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.. Because the pushed request contained a redirect_uri, the 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. request repeats it, just as it would have if the address had travelled in the browser. Nothing in the code exchange changes.
Single use and a short life
The request URI passes through Ava's browser, so it is exposed in the same ways any URL is. It can end up in history or a log, and someone who copies it could try to start the same authorization in a browser of their own. Four properties keep that from being useful.
Single use. Once the reference has been used, a copy is worth nothing. The specification says servers should treat request URIs as one-time use, and allows them to tolerate a repeated visit when someone reloads the page. Some servers apply the single use when the authorization is completed rather than when the page first loads, so that a link preview or a browser that fetches pages in advance does not use up the reference before Ava arrives.
A short lifetime. An unused reference stops working after its expires_in. The lifetime has to be long enough for a slow network or a phone that asks which browser to open, and short enough that a copy found later has already expired.
Bound to one client. Suppose an attacker registered their own client with the photo service, pushed a request naming their own return address, and then sent Ava a link carrying that reference with client_id=photo-printer. The consent screen would show the printer's name while the stored request sent the result to the attacker. The binding check in step 3 refuses that combination.
Unguessable. The random part of the reference means nobody can produce a valid one for a request they did not push.
Ava's browser
- Within 90 seconds
- Yes
- Unused
- Yes
- Pushed by photo-printer
- Yes
Sign in and consent
An hour later
- Within 90 seconds
- No
- Unused
- No, Ava used it
- Pushed by photo-printer
- Yes
invalid_request_uri
Their own reference
- Within 90 seconds
- Yes
- Unused
- Yes
- Pushed by photo-printer
- No, another client
Refused by the binding check
Parameters added beside a reference are ignored or refused.
The printer has a matching duty: it uses each reference once. If Ava closes the photo service tab and selects Connect again, the printer pushes a new request rather than reusing the old reference. The stored request contains values that belong to one attempt, such as state and the PKCE challenge, and a new attempt needs new ones.
What the browser can still affect
PARAn OAuth extension, RFC 9126, in which the client sends its authorization request straight to the authorization server and gets back a short-lived request_uri. The browser carries only that reference, so the parameters cannot be read or changed on the way. removed the parameters from the browser, but the browser still carries two things: the reference on the way in and the response on the way out.
An attacker who captured a request URI from someone else's attempt might try swapping it into Ava's, hoping her approval completes a request she never saw. That stored request carries the state and PKCE challenge of the attempt that created it. When the response comes back to Ava's sessionThe ongoing connection between later requests and an earlier sign-in, so you are not asked for your password on every click. It is often tracked with a cookie holding an unpredictable session identifier., the state does not match the printer's pending attempt for her, and the code cannot be redeemed without the other attempt's verifier. This is one reason a pushed request should always include state and a PKCE challenge, even though nobody can edit them in transit any more.
The response is unchanged by PAR. The code, state and iss come back in an ordinary redirect, readable and recordable like any URL, and the printer applies every check from Correlating requests and responses before it uses them. Protecting the response itself takes a different mechanism, the signed responses of Protecting an authorization response.
Errors from the push
So far every step has succeeded. A pushed request can fail in two places, and the failures look different, reach different parties and call for different responses. The first place is the push itself, refused in a direct response to the printer's backend.
Suppose a developer changed the printer's callback path in the code but not in its registration. The push fails:
HTTP/1.1 400 Bad Request
Content-Type: application/json
Cache-Control: no-cache, no-store
{
"error": "invalid_request",
"error_description": "The redirect_uri is not valid for this client"
}The error uses the same JSONA text format for structured information, written as named values inside curly braces. APIs, tokens, and discovery documents all use it. format as a 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. error, and its code comes from the token endpoint's list or the authorization endpoint's list, whichever fits. A return address problem is a useful case to notice. In the browser, that mistake would have left Ava on an error page at the photo service, because the service may not redirect to an address it cannot trust and the specification defines no error code for that case. At the PAR endpoint there is no redirect to worry about, so the service can say what went wrong, using invalid_request by default. Each row of the table pairs a response with its usual cause and what the printer should do next:
| Response | Usual cause | The printer's next step |
|---|---|---|
400 invalid_request | A malformed request, or a return address not valid for this client. | Treat it as a configuration fault. Retrying the same push will fail the same way. |
401 invalid_client | Client authentication failed. | Check the deployed credential against the registration, as for the token endpoint. |
400 invalid_scope or unauthorized_client | The printer asked for something its registration does not allow. | Fix the request or the registration. |
413 | The request is larger than the service accepts. | Reduce the request. |
429 | Too many pushes from this client in a period. | Wait before trying again. |
Some errors never come from this endpoint. Because nobody has been asked to sign in or approve anything yet, errors about signing in or consent are decided later, in the browser. A request sent with any method other than POST gets 405.
Whatever the error, Ava's browser has not gone anywhere. She is still on the printer's page, so the printer can tell her that it could not connect her photo account right now and record a safe diagnostic for its developers. It should not fall back to building an ordinary authorization URL, which would quietly give up the protection it chose PAR for.
Parameters in two places
The printer sends only client_id and request_uri to the authorization endpoint. Suppose someone edits the address in the browser to add more:
https://auth.photos.example/authorize
?client_id=photo-printer
&request_uri=urn%3Aietf%3Aparams%3Aoauth%3Arequest_uri%3Ademo-pushed-request-7
&scope=photos.read%20photos.deleteThe added scope has no effect. Under the borrowed rules, the service uses only the parameters it stored for the reference. Values added to the URL are ignored, and a stricter service refuses a request that carries them. Either way, an edit in the browser cannot change what the printer pushed. High-assurance profiles go further and require clients to send nothing but client_id and request_uri to the authorization endpoint. client_id is the one value that appears in both places, which is why the binding check insists that the two agree.
Requiring PAR and choosing return addresses
A service that offers PAR but still accepts ordinary authorization URLs has added a safer route without closing the old one. Anyone can still write an ordinary URL naming the printer, with whatever parameters the registration allows. The protections apply only to requests that take the new route.
Closing the old route is a policy setting, and it can be announced in metadata, the JSON document where the service lists its endpoints and features. For the whole service, the setting appears in 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.'s metadata. For one client, it can be recorded in that client's registration:
Authorization server metadata (excerpt):
{
"issuer": "https://auth.photos.example",
"authorization_endpoint": "https://auth.photos.example/authorize",
"pushed_authorization_request_endpoint": "https://auth.photos.example/par",
"require_pushed_authorization_requests": false
}
Client registration for photo-printer (excerpt):
{
"require_pushed_authorization_requests": true
}Here the photo service does not require PAR from every client, but it does from the printer. Any authorization request for photo-printer that lacks a request URI obtained from the PAR endpoint is refused with invalid_request. Both settings default to false when omitted.
PAR can also change how return addresses are handled. Exact matching against the registered list remains the normal rule. Because the service authenticates the client before the authorization begins, the specification allows a service to relax that rule for clients with credentials, accepting a return address the client supplies in the push without registering it first. A client could then use a distinct address for each authorization server it works with, chosen at run time. The service decides whether to allow this and can still limit it, for example by requiring every such address to start with https://printer.example/oauth/.
That freedom must never extend to unauthenticated pushes. If anyone could push a request with a return address of their choosing, the photo service would send people and their codes wherever an attacker liked. 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., which cannot authenticate, keeps to its registered addresses.
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
- Redeem a pushed request URI, break it, then require PARComplete a code flow where the browser carries only client_id and request_uri, show the reference is single use and bound to its client, meet push errors, then require PAR for lab-printer.