Expiration and nonce checks
Three times in an 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., and one value the relying partyAn application that accepts and relies on a sign-in from another service, the name used in OpenID Connect and for passkeys. SAML calls the same role a service provider. chose itself, answer the last questions: whether 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. is current, how recently the person proved who they are, and which sign-in attempt the token belongs to.
Checking the clock
The collage app finishes checking Ava's ID token at 09:00:02 UTC, two seconds after the photo service issued it. By then it knows who made the statement and whom it was made for. All domains, identifiers and tokens in these examples are fictional.
Like all JWTA JSON Web Token: a compact token made of Base64url-encoded parts that carries claims and is usually signed. Anyone holding it can decode and read the claims, so the signature shows who issued it but hides nothing. times, the three in Ava's token count seconds since 1 January 1970 UTC:
| Claim | Value | Time on 1 October 2026 (UTC) |
|---|---|---|
iat | 1790845200 | 09:00:00, when the photo service issued the token. |
exp | 1790845500 | 09:05:00, from which the token must not be accepted. |
auth_time | 1790845185 | 08:59:45, when Ava last authenticated at the photo service. |
The rule for exp is strict: the current time must be before it. At 09:00:02 her token has almost five minutes to spare. Two servers rarely agree to the second, though, so the collage app allows a small tolerance for the difference between its clock and the photo service's, usually called leeway. The specification describes it as small, usually no more than a few minutes. For servers that keep accurate time, a minute is plenty.
Five minutes is a generous life for a token the collage app checks within seconds of receiving it, and the shortness is deliberate. The token speaks about one moment, and one that stayed acceptable for hours would be worth stealing for hours.
iat gets a check of its own. The specification lets a relying party reject a token issued too far from the current time and leaves the range to the client. The collage app refuses an ID token issued more than five minutes before it arrives, whatever its exp says, or one issued further in the future than its leeway allows. A token from the future means a clock is wrong somewhere, or the token is not what it appears to be. The same window also limits how long a relying party has to remember nonces, as the last section explains.
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. does not define nbf, "not before", for ID tokens, but it is a standard JWT claim. If a provider includes one, the collage app's library checks that the current time is not before it, with the same leeway.
All of this rests on the collage app's own clock. Its servers keep time with a network time service, because a server that runs a few minutes fast rejects valid tokens as expired, and one that runs slow keeps accepting tokens after they should have expired. When validation fails returns to how those faults show up.
Issued at and authentication time
ID tokens and access tokens pointed out that iat and auth_time can be far apart. In Ava's token they are fifteen seconds apart, because she signed in at the photo service at 08:59:45 and the token was issued at 09:00:00. The next morning shows the difference.
Ava selects Continue with your photo account again. The photo service still has her 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. from yesterday, so it asks her nothing and sends the collage app a new ID token straight away. Its times read:
iat 1790931600 2 October 2026, 09:00:00 UTC
auth_time 1790845185 1 October 2026, 08:59:45 UTCThe token is seconds old. The 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. behind it is a day old. That is single sign-onSigning in once and then using several applications without entering credentials again, usually because they all rely on the same identity provider. working as intended, and for arranging a collage it is fine. Before the collage app deletes Ava's collages or changes the email address on her account, though, it may want proof that she, and not someone at a computer she left signed in, is there now. That decision has to use auth_time. A relying party that read iat as the moment Ava signed in would believe she had just proved who she is.
1 October
- auth_time
- 08:59:45 UTC
- iat
- 09:00:00 UTC
Fifteen seconds apart
2 October, no new sign-in
- auth_time
- 1 October, 08:59:45 UTC
- iat
- 2 October, 09:00:00 UTC
The authentication behind it is a day old
That decision has to use auth_time.
auth_time is not always present. The provider must include it when the request set max_age, when the request asked for auth_time as an essential claim (one the request marks as required), or when the client registered to receive it every time. Otherwise it may leave it out. The collage app registered to receive it every time, a registration setting that Registering a relying party describes, so every ID token the photo service sends it carries the claim. Not every relying party registers that way, so two rules apply. If a relying party asked for auth_time in any of those ways and the claim is missing, it rejects the token. If it did not ask, a missing auth_time means the time is unknown, never that the sign-in was recent.
acr works the same way. When the collage app asked for a particular kind of authentication, it checks that the value in the token is one it accepts, and a missing value does not count as a yes. Session age and reauthentication covers how the collage app asks for a recent sign-in, and Authentication context and methods covers acr.
Matching the nonce
State and nonce explained why the collage app sends demo-nonce-3 and how 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. exposes an injected code. Here is where the comparison sits. It comes after the 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., because a nonce means something only inside a token the photo service has signed. Then the claim is compared with the value stored in the attempt, as an exact, case-sensitive string:
Token's nonce | Result | Why |
|---|---|---|
demo-nonce-3 | Accepted | The token answers this attempt. |
demo-nonce-2 | Rejected | The token was issued for Ava's earlier sign-in, not this one. |
Demo-Nonce-3 | Rejected | Nonces are compared exactly, including case. |
| Missing | Rejected | The request sent a nonce, so the token must carry it. |
The demo-nonce-2 row is the replay. A few days earlier Ava signed in with her photo account for the first time, and the token from that attempt carried demo-nonce-2. Suppose a token carrying another attempt's nonce, like that one, turns up now in place of this attempt's token, whether through a stolen code as in State and nonce, a captured response, or a bug that mixed up two attempts. Every other check can pass. The photo service really did sign it, for the collage app, about Ava, and if it came from a stolen code redeemed just now, even its times are fresh. Only the nonce shows that it answers a different request. The comparison does not need to know how the token arrived.
A nonce is satisfied once. The collage app stores it in the pending attempt and claims the attempt as the callback is processed, so a second token carrying demo-nonce-3 finds nothing to match. A relying party that does not keep a record per attempt, such as one that holds the nonce in a protected 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. as State and nonce described, can instead record the nonces it has accepted and refuse any of them a second time. The iat check limits how long that record must last: a token issued before the window fails the time check anyway, so a used nonce needs remembering only for as long as the window.
The rule that a missing nonce fails has one more use. A provider can sign other JWTs that name the collage app as their audience. Back-channel logout introduces one, the logout tokenA signed JWT that an OpenID Provider sends directly to a relying party's server to say that a person's session at the provider has ended, naming them by sub, sid, or both. The relying party validates it like an ID token and ends its own matching session., and its specification forbids a nonce in it precisely so that a relying party which checks for one will never accept a logout token as an ID token.
ID tokens returned when a refresh token is used are the exception, because no new authentication request, and so no new nonce, stands behind them. Offline access and refresh behavior covers how the collage app checks those.
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
- Watch an ID token expire, separate iat from auth_time, and match nonces exactlyShorten lab-collage's ID token lifetime, let a real token expire, see single sign-on keep an old auth_time, enforce max_age, and refuse nonces that differ by case or attempt.