When validation fails
Rejecting 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. that fails validation is right, but it is only the start. Someone has to work out what kind of failure it is, tell the people affected something useful without helping an attacker, and repair the cause without turning the repair into a new weakness.
Sorting the failures
At 09:12 on a Tuesday, the collage company's support team receives a message: "Continue with your photo account just brings me back to the sign-in page." By 09:30 there are forty more. Behind each one is a sign-in whose 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. the collage app rejected, and the collage app did what Validating an ID token required of it. It signed nobody in.
All domains, identifiers and log values in these examples are fictional.
The collage app's records show where each sign-in stopped, and the pattern across them says where to look first. It does not say who caused the failures. 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 come from two sign-ins overlapping in one browser, or from the collage app storing its attempts badly. An unknown key can follow a legitimate rotation, a failed fetch, or a token from a provider the collage app never configured. Finding the failing stage in general is taught in Finding the failing stage; here the stage is already known, because validation stopped the sign-in. What remains is which check failed, what the collage app compared the token against, and how that differs from a sign-in that worked. The usual answers fall into four kinds:
| Kind | What the pattern looks like | Common causes |
|---|---|---|
| Configuration mismatch | Every sign-in fails at the same check, starting at a release or a change at the provider. | An issuer with a trailing slash, a test client ID in production, an algorithm the provider has moved to that the list lacks, a key set address from the wrong environment. |
| Clock problems | Time checks fail: tokens look expired on arrival, or issued in the future. Often only some servers are affected. | A server whose clock has drifted, or a virtual machine resumed with a stale clock. |
| Key set unavailable | A token names a key the collage app does not hold, and fetching the set fails or times out. | A network or firewall change, an outage at the provider, a rotation the collage app could not follow. |
| Scattered validation failures | Failures at the signature, audience, or nonce checks, with no known deployment change. | A replayed or altered token, a bug that mixes up two attempts, or a configuration change nobody noticed. Any of them is possible, so the team investigates before naming one. |
Tuesday's failures were all at the audience check, and they began at 09:10, two minutes after a release. That pattern points at configuration, and so it proved. The release had upgraded the collage app's OpenID ConnectAn identity layer on top of OAuth 2.0 that lets an application sign people in with an account at another service. It adds the ID token, standard claims, and discovery to the OAuth exchange. library, and the new version read the expected audience from a setting with a new name. With its old setting ignored, the library had no expected audience at all. As Validating an ID token asked of it, the library rejected every token rather than skip the check, while the photo service, correctly, kept sending photo-collage.
The other kinds leave their own traces. Clock faults come and go with the server that handled each request, and the gap between the token's times and the server's clock is about the same each time. 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. failures arrive alongside errors from the fetch itself. They also call for a decision made in advance. If a token names a key the collage app already holds, from a set it fetched recently, the collage app can keep validating with that copy while the provider recovers. If the key is unknown and the set cannot be fetched, the collage app has no way to verify the token, so the sign-in fails.
The repair was to give the library its expected audience under the new setting's name, check it against the collage app's registration for production, and try a fresh sign-in. Accepting more audiences would not have helped: the tokens were already addressed to the collage app.
What the person sees
From the person's side, all four kinds look the same, and they should. The collage app shows the page that Authentication errors described for any failed sign-in, with one addition, a reference:
We couldn't sign you in with your photo account.
Try again, or sign in another way.
Reference: signin-5f2cTrying again starts a new attempt with a fresh state, nonce, and 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. verifier. The failed attempt was claimed when the callback arrived, so nothing from it can be reused. The collage app does not retry by itself. An automatic retry can bounce a browser between the collage app and the photo service, and when the cause is configuration, every retry fails the same way.
The page does not say which check failed. "Nonce mismatch" or "invalid audience" means nothing to someone making a collage, and to someone testing forged tokens it reports how far each one got. The page shows nothing from the rejected token either. A name or email address inside a token that failed validation is unverified text, possibly written by an attacker, so "Welcome back, Ava" has no place here. The reference lets a person who contacts support be matched to the collage app's records without anyone reading out a token.
When the fault is the collage app's own, as on Tuesday, everyone sees the same page until the fix is deployed. A short notice on the sign-in page saying that sign-in with the photo service is having problems saves people from trying again and again.
What the logs record
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. errors set out the basics: the stage, the failed check, the expected 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., and a correlation ID, and never the code or the tokens. A validation failure needs a few more fields to be diagnosable. One of Tuesday's entries:
{
"time": "2026-10-06T09:12:04Z",
"event": "sign_in.id_token_rejected",
"message": "Sign-in rejected: the ID token failed the audience check",
"stage": "id_token_validation",
"check": "audience",
"expected_issuer": "https://auth.photos.example",
"expected_audience": null,
"kid": "photos-rs-2026-09",
"alg": "RS256",
"token_age_seconds": 2,
"server": "web-3",
"correlation_id": "signin-5f2c"
}The stage and check say where validation stopped. The expected values show what the collage app compared against, and on Tuesday they were the whole answer: anyone reading this entry could see that the collage app had no expected audience at all. The kid and alg come from the token's header and separate key problems from others. token_age_seconds, the server's time minus the token's iat, exposes a drifting clock, since a negative age means a token from the future. The server name shows whether failures follow one machine. The correlation ID is the reference the person saw, and it ties this entry to the callback and the token request before it.
What the entry leaves out matters as much. It never holds the ID token, the access tokenA token that a client presents to an API to use access it has been granted, usually limited in what it allows and how long it lasts. It authorizes API calls; it does not tell the client who signed in. from the same response, the 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., or the state and nonce values. Logs are read by more people and kept longer than most of what the collage app stores, and the access token beside the ID token is a working credential. Ava's name and email address stay out too. When a value from the rejected token would genuinely help, such as the issuer it named when the issuer check failed, the collage app records it shortened and marked as unverified, because anyone can write anything into a token that has not passed.
Entries like this are most useful in aggregate. Counting failures by check, server, and provider each hour turns Tuesday into a single line on a graph that jumps two minutes after the release. A rise in signatureA value made with a private key that lets anyone holding the matching public key check that a message came from the key's holder and has not been changed. It proves origin and integrity; it does not hide the message. or nonce failures with no release behind it is the signal that someone is trying tokens they should not have.
Fixes that make things worse
A sign-in outage invites quick fixes, and the quickest ones switch off the check that failed instead of correcting what it compared against:
| Tempting fix | What it actually does | Fix instead |
|---|---|---|
| Turn off the audience check | Accepts ID tokens the photo service issued to any client, including the collage app. | Set the expected audience to photo-collage. |
| Accept whatever algorithm the header names | Brings back unsigned tokens and the HMAC confusion attack. | Confirm the provider's change, then add that one algorithm. |
| Widen the clock tolerance to an hour | Accepts expired tokens for an hour and widens the window for replays. | Repair the server's time synchronization. |
| Finish sign-ins whose pending attempt cannot be found | Removes what state and the nonce protect against: forged callbacks, injected codes, and replayed tokens. | Find out why the attempt is missing. |
| Use a key from the token when the key set is unreachable | Lets anyone sign a token with a key of their own and pass. | Use the cached set, retry with limits, and fail the sign-in otherwise. |
The missing-attempt row usually traces back to a 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.. Request correlation and CSRF followed a team whose callback stopped receiving its session cookie after a SameSite change. Without the attempt the cookie leads to, there is no state to match and no nonce to compare. The repair is the one that lesson gave for the cookie, not a callback that finishes without its attempt or searches every attempt for one that fits.
The most dangerous fix rarely looks like a decision at all. It is an error handler that records the failure and carries on, or a fallback that, when the ID token will not validate, asks the UserInfo endpoint who the access token belongs to. Authentication errors ruled out that fallback for a response with no ID token, and it is no safer for one whose ID token failed. UserInfo can describe whoever the access token belongs to, but it cannot prove that this response answers the collage app's own pending attempt. A failed validation ends the sign-in: the handler records a safe reason, discards the tokens, and creates no account link or session.
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 audience, algorithm and key set failures from evidenceCompare a working sign-in with audience, algorithm and key set refusals, repair each at its cause, and read the pattern from a safe rejection log.