OAuth 2.0 Error: `invalid_grant` (Authorization Code Reused or Expired)

Single-use auth code was redeemed twice, expired (>60s), or PKCE `code_verifier` mismatched.

Runs locally in browser Free · No login Independently Verified 2026-11-25 v4.1.0
Identifier: OAuth 2.0 Error Platform: Security
Common Root Causes:
  • Single-use auth code was redeemed twice, expired (>60s), or PKCE `code_verifier` mismatched.

Interactive Diagnostic Checklist

Verified Solutions:
  1. Exchange auth codes once immediately on callback and ensure `code_verifier` matches `code_challenge`.
Safe Diagnostic Command:
Verify single token exchange & PKCE S256 verifier
Warning: Verify configuration changes in staging or with dry-run flags (e.g. nginx -t) before reloading production services.

Technical Explanation

Single-use auth code was redeemed twice, expired (>60s), or PKCE `code_verifier` mismatched. Recommended diagnostic: `Verify single token exchange & PKCE S256 verifier`. Remediation: Exchange auth codes once immediately on callback and ensure `code_verifier` matches `code_challenge`.

Worked Examples

  • Run `Verify single token exchange & PKCE S256 verifier` to verify root cause before applying the remediation.

Limitations & Assumptions

  • Always verify configuration changes in staging or with dry-run flags (e.g. `nginx -t`) before reloading production services.

Source References & Verification

Resource ID: err-oauth-invalid-grant-expired-code · Independently verified: 2026-11-25

Related Resources