moodle/moodle · error · Google_Auth_Exception
No issue time in token: $json_body
Error message
No issue time in token: $json_body
What it means
The JWT payload decoded from the token body has no 'iat' (issued-at) claim, or it is 0. verifySignedJwtWithCerts requires iat to compute the earliest acceptable time window, so a token without it is rejected.
Solutions
- Ensure the token issuer includes the 'iat' claim as a numeric Unix timestamp in the payload.
- If you mint test JWTs, add iat: time() before signing.
- Only pass Google-issued ID tokens to verifyIdToken(); validate other tokens with the appropriate issuer's library.
Example fix
// before (minting a test JWT) $payload = ['exp' => time() + 3600]; // after $payload = ['iat' => time(), 'exp' => time() + 3600];
Defensive patterns
Strategy: validation
Validate before calling
$payload = json_decode(base64_decode(str_replace(['-', '_'], ['+', '/'], explode('.', $token)[1]) . '=='), true);
if (empty($payload['iat'])) { throw new InvalidArgumentException('Token missing iat claim'); } Type guard
function hasIat(array $payload) { return isset($payload['iat']) && is_numeric($payload['iat']) && $payload['iat'] > 0; } Prevention
- Only verify standard OIDC ID tokens, which always carry iat
- If minting test JWTs, always include numeric iat and exp claims
- Never modify the JWT payload in transit
When it happens
Trigger: verifyIdToken()/verifySignedJwt() called with a token whose JSON body lacks the 'iat' field — typically a non-standard or hand-crafted JWT, or a token whose payload decodes to an object without iat.
Common situations: Developers minting their own JWTs for testing without setting iat, tokens issued by non-Google systems being validated against Google certs, or iat encoded as a string "0"/null after bad JSON manipulation.
Related errors
- No expiration time in token: $json_body
- Cannot sign both audience and scope in JwtAccess
- Expiration time too far in future
- Invalid issuer, not in
- Invalid token signature: $jwt
AI-assisted analysis of moodle/moodle@48ea8c3322 (2026-09-14).
Data as JSON: /api/errors/5263bfc3cb4031e4.
Report an issue: GitHub.
Appendix: source
Thrown at public/lib/google/src/Google/Auth/OAuth2.php:564
foreach ($certs as $keyName => $pem) {
$public_key = new Google_Verifier_Pem($pem);
if ($public_key->verify($signed, $signature)) {
$verified = true;
break;
}
}
if (!$verified) {
throw new Google_Auth_Exception("Invalid token signature: $jwt");
}
// Check issued-at timestamp
$iat = 0;
if (array_key_exists("iat", $payload)) {
$iat = $payload["iat"];
}
if (!$iat) {
throw new Google_Auth_Exception("No issue time in token: $json_body");
}
$earliest = $iat - self::CLOCK_SKEW_SECS;
// Check expiration timestamp
$now = time();
$exp = 0;
if (array_key_exists("exp", $payload)) {
$exp = $payload["exp"];
}
if (!$exp) {
throw new Google_Auth_Exception("No expiration time in token: $json_body");
}
if ($exp >= $now + $max_expiry) {
throw new Google_Auth_Exception(
sprintf("Expiration time too far in future: %s", $json_body)
);
}
View on GitHub (pinned to 48ea8c3322)