Diagnosing sign-in failures
A sign-in can fail at any of its stages, and each stage leaves different evidence. This lesson follows three customers' failures at the collage app, before the ID tokenIn OpenID Connect, a signed JWT from the provider, addressed to one client, saying which account authenticated, when, and in answer to which request. It reports a sign-in and is not used to call APIs., at ID 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. validation and in a sign-in loop, and finds each one from the stage where it stopped.
Finding the stage
All domains, identifiers, and log values in these examples are fictional.
On Monday morning, the collage app's support queue has three new messages. The first customer says that Continue with your photo account shows an error page at the photo service. The second says sign-in worked last week, but now it returns them to the collage app with "We couldn't sign you in." The third says the screen keeps flickering between the two sites until the browser gives up.
All three are sign-in failures, and each stopped somewhere different. Diagnosing them starts with finding where.
A sign-in passes through its stages in a fixed order, and each leaves different evidence behind:
| Stage | Where the person ends up | What the collage app can know |
|---|---|---|
| The request | On the provider's error page | The redirect URI, scopes, and other parameters it sent |
| At the provider | Still at the provider | Only that the pending attempt was never completed |
| The callback | Back at the collage app, with an error | Whether a pending attempt matched, the iss received, and any error code |
| The token exchange | Back at the collage app, with an error | The HTTP status and error code from the token endpoint |
| ID token validation | Back at the collage app, with an error | The failing check, the issuer, the kid, and the token's times |
| Account and session | Signed in to the wrong account, or not for long | The issuer and subject looked up, and whether the session cookie came back |
No single party sees the whole sign-in. The browser sees the redirects and which cookies it sends, the photo service knows what it accepted and issued, and the collage app knows whether a callback matched a pending attempt, what its checks decided, and whether a 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. started. So the method is to walk the stages in order and find the last one that succeeded: the failure lies in the stage after it, and that stage's own evidence says why. The Troubleshooting lesson Finding the failing stage applies the same method to failures of every kind. For a sign-in, one reading needs care: a callback missing from the collage app's records means the browser never delivered one, not that the photo service refused it. The records are only as useful as the fields When validation fails listed: the stage, the failing check, the issuerThe party that creates and signs a token, assertion, or certificate, named in a token's iss claim. A recipient must check that the issuer is exactly the one it expected and trusts., the key identifier, and a correlation ID, never the code or the tokens.
Before the ID token
The first customer never came back to the collage app, so the failure is at the first stage. The collage app's records agree: an attempt created at 08:02 for this customer, never claimed, expired ten minutes later. The only thing the collage app controlled was the request it sent, so the support engineer compares the redirect_uri in that request with the addresses registered at the photo service, character by character:
sent: https://www.collage.example/signin/callback
registered: https://collage.example/signin/callbackThe customer had arrived on www.collage.example, and a release on Friday had started building the return address from the host of the incoming request instead of from configuration. The photo service compares redirect URIs exactly, and it must not send anyone to an address it does not recognize, so it showed its own error page and sent nothing back. The repair is to take the return address from the collage app's configuration again. Registering the www address as well would make the error page go away, but it would not have saved the sign-in, for a reason that comes up again in the third case: the pending attempt's cookieA small value that a website asks the browser to store and send back with later matching requests. Cookies commonly carry a session identifier, so the site can recognize an ongoing sign-in without your password. belongs to the host that set it.
Other failures before the ID token look different. If the collage app comes back with an error from 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., invalid_client points at the collage app's own credentials, often a secret rotated on some servers and not others; the engineer compares which credential version each server uses, never the secret itself. invalid_grant points at the code: expired, already used, or sent with the wrong verifier or return address. And if the callback finds no pending attempt at all, the cookie that identifies the attempt did not come back with it. Three causes are common:
- The attempt cookie is
SameSite=Strict, or it isLaxwhile the provider usesform_post. A cross-site POST carries neither, as Response types, response modes, and older flows described. - The attempt started on
www.collage.example, but the registered callback is oncollage.example. A host-only cookie, such as one named with the__Host-prefix, is never sent to the other host. - The cookie expired while the person was at the provider, perhaps setting up a new authenticatorSomething a person controls and uses to prove control of an account, such as a memorized password, an app that generates one-time codes, or a security key. It counts only after it has been registered to that account., which took longer than the attempt's lifetime.
Each is repaired by restoring the binding between the browser and its attempt. Searching every stored attempt for one with a matching state would make the error disappear and remove the protection state exists for.
Rejected ID tokens
The second customer did come back, and the collage app rejected the ID token. Its record of the attempt says exactly which check failed:
{
"time": "2026-10-05T08:14:07Z",
"message": "Sign-in failed during ID token validation",
"correlation_id": "corr-5521",
"server": "app-3",
"issuer": "https://auth.photos.example",
"stage": "id_token_validation",
"check": "iat",
"kid": "photos-rs-2026-09",
"token_iat": 1791188347,
"server_time": 1791188047
}The token says it was issued at 08:19:07, five minutes after the server's idea of now. Either the photo service's clock is five minutes fast or this server's is five minutes slow, and the other records decide which. Every failure of this kind comes from app-3, while the collage app's other servers accept the photo service's tokens all morning. Checked against a reliable time source, app-3 is five minutes behind: its time synchronization stopped after a restart. The customer was unlucky enough to be served by it twice.
The repair is the clock. Widening the collage app's clock tolerance to ten minutes would let these sign-ins through and hide the drift, and it would weaken the time checks on every server, as Expiration and nonce checks explained. Once app-3 is synchronized, a fresh sign-in routed to it succeeds, and the same token arriving ten minutes late is still refused.
The other rejections read the same way, from the check that failed. An unknown kid is often an ordinary rotation: the collage app refetches the photo service's 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. from its jwks_uri, within a limit, and the sign-in succeeds. If the new key set still lacks the key, the token was signed by something the collage app does not trust, and the collage app never fetches a key from an address the token itself names. A nonceA random value used for one attempt only. In OpenID Connect, the client sends one in its sign-in request and checks that the same value comes back inside the ID token, showing the token answers this attempt. mismatch can be a replay, or a bookkeeping bug that pairs one attempt's callback with another attempt's nonce when a customer opens two tabs; the engineer checks that each state resolves to its own nonce and verifier. A genuine token with the wrong audience is still a rejection, whatever caused it, and removing the audience check is never the fix.
Sign-in loops
The third customer's screen flickered between the two sites. In a loop, each round trip ends in an answer and the collage app immediately asks again. The collage app's records for this customer show the pattern every second or two: callback matched, ID token valid, account found, session started, and then a request for the order page with no session cookie, which sends the browser back to sign in. The photo service still has a session, so it answers at once, and the cycle repeats.
The collage app is setting its session cookie, and the browser is not returning it. The response headers from the callback, read in the browser's developer tools without copying the cookie's value, show why:
Set-Cookie: __Host-collage-session=...; Domain=collage.example; Path=/; Secure; HttpOnly; SameSite=LaxA cookie whose name starts with __Host- must be Secure, must have Path=/, and must have no Domain attribute. The same Friday release had added Domain=collage.example so that the session would reach www.collage.example too, and browsers refuse to store a __Host- cookie that names a domain. They do so silently, so the only symptom is a session that never arrives. Removing the attribute, and sending every customer to one host, ends the loop.
The other common loop does not show on screen. A silent prompt=none check, made to find out whether Ava is still signed in at the photo service, can return login_required because no usable provider session reaches that request. That is an answer, not an error to retry. A collage app that sends the same silent request again at once loops in the background, and the photo service sees a stream of identical requests. The collage app treats the answer as final, offers Ava a Sign in button, and asks again only after something changes, such as her choosing to sign in.
Each repair is proved in both directions: a fresh attempt through the repaired path reaches the session, and the check that failed still refuses what it should.
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
- Diagnose a sign-in from evidence at each stageStart from a working sign-in, then find the failing stage for a bad return address, a key rotation, token endpoint errors and a silent-request loop, without weakening a check.