Skip to content
ecdsa.com
PyJWT (Python)JWT libraries

Error message

The token is not yet valid (iat)

Also printed as

  • The token is not yet valid (nbf)
  • jwt.exceptions.ImmatureSignatureError: The token is not yet valid (iat)

The claim in parentheses is `iat` or `nbf`. PyJWT 2.0–2.5 accepted an `iat` in the future; 2.6.0 started rejecting it, so an upgrade from an old version can surface clock skew that existed all along.

PyJWT (Python) — jwt.exceptions.ImmatureSignatureError

What it means

PyJWT's `ImmatureSignatureError`: the token's `iat` (issued at) or `nbf` (not before) is later than the verifier's current time. The name in parentheses tells you which claim. PyJWT rejects tokens issued "in the future" because a correct issuer cannot produce one; in practice this almost always means the issuer's clock is ahead of yours.

Why it happens

How to fix it

  1. 1.

    Allow a small leeway

    `leeway` (seconds or a `timedelta`) tolerates clock differences for `exp`, `nbf` and `iat`. Keep it to tens of seconds, and fix the drifting clock with NTP.

    python
    from datetime import timedelta
    
    claims = jwt.decode(
        token,
        signing_key,
        algorithms=["ES256"],
        audience="https://api.example.com",
        leeway=timedelta(seconds=30),  # applies to exp, nbf and iat
    )
  2. 2.

    Measure the skew

    Print each time claim relative to the local clock. A small positive `iat` means skew; a huge one means a unit bug in the issuer.

    python
    import time
    
    c = jwt.decode(token, options={"verify_signature": False})
    now = int(time.time())
    print({k: c[k] - now for k in ("iat", "nbf", "exp") if k in c})  # seconds relative to this host

Related errors

Browse the full signature error database