nonce
recommendedscope: openid (optional, recommended)Type: string (case-sensitive)
nonce is an anti-replay value sent in the authorization request and embedded in the ID Token. Clients that include a nonce in the authorization request MUST verify the nonce in the ID Token matches. This prevents replay attacks where an attacker reuses a valid ID Token.
Details
The nonce ties an ID Token to a specific authentication session.
Flow: 1. Client generates a random nonce and stores it (e.g., in session or localStorage) 2. Nonce is included in the authorization request (&nonce=abc123) 3. Provider embeds nonce in the ID Token 4. Client verifies nonce in token matches what was sent
If nonce was sent in the authorization request, its presence in the ID Token is REQUIRED. If the token doesn't contain the expected nonce, reject it.
Nonce prevents replay: if an attacker captures an ID Token (e.g., from server logs), they cannot replay it because the nonce has already been used and the client's session has moved on.
Nonce storage: store nonce in server-side session (for web apps) or in a secure, short-lived local store. Never store in a cookie without HttpOnly + SameSite protection.
Example Values
| Label | Value |
|---|---|
| Random nonce | "S1X8qhftzLYaE9lmxVm9Xg==" |
Validation Rules
If sent in authorization request, MUST be present and match in ID Token
Generate cryptographically random nonce per authorization request
Reject token if expected nonce is not present
Never reuse a nonce across multiple authorization requests