Google Client Invalid JWT: Token must be a short-lived token

Google Client Invalid JWT: Token must be a short-lived token

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Decoding the "Token must be a short-lived token" Error

When working with Google's PHP API client library and service accounts, encountering an invalid_grant error is a common friction point in authentication workflows. The specific message, "Invalid JWT: Token must be a short-lived token (60 minutes) and in a reasonable timeframe," signals a mismatch between the claims embedded in your JWT and the strict validation rules enforced by Google's infrastructure. While many developers immediately assume a system clock issue, the root cause often lies deeper in how the Identity Access Token is generated and validated.

The error explicitly points to checking iat (issued at) and exp (expiration) values. In the context of service accounts, the PHP client library constructs an assertion containing these timestamps. Google validates this assertion by calculating the current server time and comparing it against these claims. If the token's expiration (exp) is more than 10 minutes in the past or if the issuance time (iat) suggests the token was created significantly earlier than expected, the grant is rejected. This mechanism prevents replay attacks and ensures that tokens are used within a narrow window of validity.

A frequent misconception is that setting the system timezone alone resolves timing discrepancies. While it is true that incorrect system time is a primary culprit, simply calling date_default_timezone_set in your PHP application does not guarantee accuracy if the underlying operating system clock is drifted or if the server's NTP synchronization is lagging. However, even with perfectly synced atomic clocks, you may still hit this error if the token generation logic produces an exp timestamp that falls outside Google's acceptable window relative to the current time.

The core of the problem often lies in the skew between your application's clock and Google's server clock. Google allows for a reasonable timeframe, but they enforce a strict limit on how far back or forward the token can be valid. If your local machine thinks it is 12:00 PM UTC, but Google's server thinks it is 12:05 PM UTC, a token generated with an expiration time of exactly 60 minutes from your local clock might already be considered "expired" by Google when they validate it. The library attempts to account for this using a clock skew tolerance, but if the drift exceeds the configured threshold or if the token was issued too long ago, the validation fails.

To troubleshoot this, you must ensure that the environment generating the assertion is strictly synchronized with an NTP server. Beyond system time, verify that the iat and exp claims being generated align with the current UTC time. In PHP, relying on standard date functions can sometimes introduce confusion if the timezone handling isn't explicit throughout the request lifecycle. Ensure that any timestamp manipulation occurs in UTC to avoid subtle off-by-one errors.

If you are integrating this into a larger application framework like Laravel, the same principles apply. The google-api-php-client library handles the signature and claim generation internally, but it relies on the server's system time for the current timestamp when creating the assertion. If your Laravel application runs on a containerized environment where the host clock is not synchronized, or if the PHP process inherits a timezone offset that conflicts with the UTC expectation of the Google API, the token will be rejected.

The most robust solution involves ensuring your server's system time is accurate and that no code path is artificially manipulating the system time before the library generates the token. Additionally, check for any custom logic that might override the default clock skew settings or modify the assertion payload directly. By aligning your local timekeeping with UTC standards and respecting the 60-minute validity window, you can bypass the invalid_grant error and establish a stable connection to Google's APIs.

Our network