Sign-in never returns to the app
When a provider will not accept an application's return address, it refuses the sign-in on its own page and sends nothing back, so the application's logs stay empty. This lesson follows the printing site's customers stuck at the photo service, compares the two addresses character by character, and repairs the registration without loosening the comparison.
Users are stuck at the provider
All names, domains and identifiers in these examples are fictional. You are on the printing company's web team. Its site, printer.example, lets customers sign in with their photo service account so they can print straight from their albums. On Thursday afternoon the support queue fills with the same complaint. Mara writes: "I click Sign in with Photos and land on a page at the photo service that says We can't send you back to this application. There's a reference number at the bottom. I tried three times."
Your first instinct is to open the site's own logs, and they are strangely quiet. No callback errors, no failed 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. exchanges, nothing for Mara at all. What the site does record is every sign-in it starts, because it builds 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. request before sending the browser to the provider:
window auth.start callback.received token.exchange
13:30-13:45 398 391 391
13:45-14:00 412 57 57
14:00-14:15 436 0 0Attempts start at the usual rate, and since about 13:53 none of them come back. Here is one of those requests, as the site logged it, with the per-attempt values redacted. Its parameters are the ones The authorization request described, including the redirect_uri the photo service should send Mara back to:
https://auth.photos.example/authorize
?response_type=code
&client_id=printer-web
&redirect_uri=https%3A%2F%2Fprinter.example%2Foauth%2Fcallback
&scope=openid%20photos.read
&state=<redacted>
&code_challenge=<redacted>
&code_challenge_method=S256Mara's reference number is the photo service's request ID for the page she saw. It identifies one request and grants nothing, so it is fine to have in a ticket. Ask her for that and the time she tried, not for a screenshot of her address bar.
Why the app's logs are empty
Fetch the same authorization 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. yourself and look at the raw response:
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=utf-8
Cache-Control: no-store
X-Request-ID: 3f9a6c21-0d84-4e7b-b915-6a2e8c47d0f3
<!doctype html>
<title>Sign-in problem</title>
<h1>We can't send you back to this application</h1>
<p>The return address in this request is not registered for this application.</p>
<p>Reference: 3f9a6c21-0d84-4e7b-b915-6a2e8c47d0f3</p>The important part is what is missing. There is no Location header, so the browser is not redirected anywhere. Most authorization errors do travel back to the application, as a redirect to its callback such as https://printer.example/oauth/callback?error=access_denied&state=... when a user declines, as Errors and denied access showed. This one cannot. RFC 6749 says that when the redirect URI is missing, invalid or does not match, 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. should tell the user about the error and must not redirect the browser to that address. The provider has no reason to trust an address it cannot match to the registration, and it will not send a code there, or even an error. It shows its own page instead.
That is why the site's logs are empty. The failure happened entirely at the provider, before anything returned, so the evidence lives in the provider's records. A counter of started attempts against callbacks received, like the one above, is the quickest way to notice this pattern from the application's side.
If you run the provider, or can ask its support team, the request ID leads to its audit record:
time 2026-10-15T14:06:41.208Z
operation oauth.authorize
outcome rejected
reason redirect_uri_mismatch
client printer-web
requested https://printer.example/oauth/callback
registered https://printer.example/oauth/callback/
request_id 3f9a6c21-0d84-4e7b-b915-6a2e8c47d0f3The record holds both values the provider compared, which is exactly what the next step needs.
Compare the complete addresses
Put the two values one above the other and read every character:
requested https://printer.example/oauth/callback
registered https://printer.example/oauth/callback/One trailing slash. Your web router sends both paths to the same handler, so to a developer they look like the same page. To the provider they are two different strings, and strings are what it compares. RFC 6749 asks the server to compare a fully registered redirect URI with simple string comparison, and 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. security best current practice, RFC 9700, requires exact string matching, for the reasons Redirect URI validation walked through. Its one exception belongs to native apps: under RFC 8252, an app that receives the response on a loopback IP address such as http://127.0.0.1:51004/callback may use any port, because the operating system picks a free one at run time, as Redirect URIs and client metadata explained. Everything else in that address must still match.
A trailing slash is one of a handful of near misses that cause most of these incidents. Each row below is a registered address and a requested one that a person would read as the same page:
| Registered | Requested | What differs |
|---|---|---|
https://printer.example/oauth/callback | https://printer.example/oauth/callback/ | Trailing slash |
https://printer.example/oauth/callback | http://printer.example/oauth/callback | Scheme, often from an app behind a proxy that terminates HTTPS |
http://127.0.0.1:8080/callback | http://localhost:8080/callback | Host: a name and an IP address are different strings |
https://printer.example/oauth/callback | https://printer.example:8443/oauth/callback | Port |
https://printer.example/oauth/callback | https://printer.example/OAuth/Callback | Path, including capital letters |
https://printer.example/oauth/callback | https://staging.printer.example/oauth/callback | A staging address sent with the production client ID |
The requested value matches what the site has always sent, so the registration is the side that moved. The client's change history at the provider confirms it. At 13:52 your teammate Mateo updated the printer-web registration to refresh its logo and description, and while he was there he retyped the callback with a trailing slash to match the style of other addresses in the console. The first refused request in the provider's records is at 13:53:06.
The second comparison, at the token endpoint
Before anyone found Mateo's change, another teammate tried a quick fix. Ingrid saw the registered value in the console and changed the site's login service to send the trailing-slash address, so that the authorization request would match. It did: sign-ins started reaching the callback again. Then every one of them failed one step later, at the token exchangeAn OAuth grant, RFC 8693, in which a client trades a token it holds for a new one, usually for another audience, with narrower access, or acting for someone. It lets a service call the next service without passing the original token along.:
POST /token HTTP/1.1
Host: auth.photos.example
Authorization: Basic <redacted>
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&code=<redacted>&redirect_uri=https%3A%2F%2Fprinter.example%2Foauth%2Fcallback&code_verifier=<redacted>
HTTP/1.1 400 Bad Request
Content-Type: application/json
Cache-Control: no-store
{"error": "invalid_grant",
"error_description": "redirect_uri does not match the value used in the authorization request"}The site's code redemption runs in a separate 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. service with its own configuration, and nobody changed that one. When the provider issues a code, it remembers the redirect URI the authorization request used. RFC 6749 requires the token request to include redirect_uri when the authorization request did, with an identical value, and refuses a mismatch as invalid_grant, as Exchanging a code for tokens described. Fixing one comparison while leaving the other alone moved the failure from the authorization endpoint to 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.. A new error after a change like that is progress, because it shows exactly which component still holds the old value.
The OAuth 2.1 draft, described in How the specifications evolve, drops redirect_uri from the token request, because 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. already ties the code to the client that started the flow. Many servers still compare it whenever a client sends it, though, so a client that sends it must send the same value both times.
Whether a refused redemption used up the code depends on the server. Some leave the code redeemable until it expires. Others revokeCancelling a credential, token, certificate, or authenticator before it would expire, so that it is no longer accepted. Whether every copy stops working at once depends on how services check it. it after any failed attempt. Either way, don't try to rescue codes from broken attempts. Users start a fresh sign-in once the fault is fixed.
Repair with the exact address
Two values now disagreed in two places, and the repair starts by deciding which address is right. The site's documentation, its session service and its staging client all use /oauth/callback without a slash, and Mateo's edit was cosmetic. So the registration goes back to exactly https://printer.example/oauth/callback, and Ingrid's change to the login service is reverted, so both components send that same value again.
Registering both addresses would also have made the errors stop. During a planned move between two addresses the site owns, listing both for a short time is reasonable, and the old one comes off when the move is finished. Here a second address would only be one more destination nobody needs. A wildcard or a prefix such as https://printer.example/* is never the repair: it lets the provider send codes to any page under that address, including ones that can leak them.
Then verify in both directions. Sign in through the site with a test account in a fresh browser session: the callback receives a code with a matching state, and the token exchange returns 200. Mara tries again and reaches her albums. Then repeat a request that must still be refused, the trailing-slash version of the authorization request:
GET /authorize?response_type=code&client_id=printer-web&redirect_uri=https%3A%2F%2Fprinter.example%2Foauth%2Fcallback%2F&... HTTP/1.1
Host: auth.photos.example
HTTP/1.1 400 Bad Request
Content-Type: text/html; charset=utf-8
X-Request-ID: c17d2e90-6b35-4f8a-8e14-0a9f5b3d72c6A 400 with no Location header, exactly as before, now for the address that is not registered. A repair that made both versions work would have fixed the symptom by loosening the comparison that keeps codes away from addresses nobody checked.
Worked example: the handoff note
The note records the interim change as well as the repair, because the next engineer will find Ingrid's edit in the history and needs to know it was tried and reverted:
Symptom: From 13:53 UTC, customers stopped at a photo service error page after
choosing Sign in with Photos. No callbacks reached printer.example.
Failing stage: Authorization request. Provider returned 400 with no Location header,
audit reason redirect_uri_mismatch (request 3f9a6c21-0d84-4e7b-b915-6a2e8c47d0f3).
Cause: Registration edit at 13:52 changed the printer-web redirect URI to
https://printer.example/oauth/callback/ (trailing slash). The site sends
https://printer.example/oauth/callback.
Interim: Login service briefly sent the slash version. Authorization succeeded,
token exchange failed with invalid_grant (session service unchanged).
Reverted.
Repair: Registration restored to https://printer.example/oauth/callback exactly.
Both login and session services send that value.
Verification: Fresh test sign-in: callback received, token exchange 200. Customer confirmed.
Trailing-slash request: still 400, no Location (request c17d2e90-6b35-4f8a-8e14-0a9f5b3d72c6).
Not changed: Client credential, scopes, other registered addresses.The verification line names the request ID of the refused near miss, so anyone can look up that the strict comparison was checked, not assumed.
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
- Bring sign-in back to its callbackAfter a teammate edits the client's registration, sign-in never returns. Find the edit, compare the complete addresses, put the registration back and keep the near miss refused at both stages.