Google-api-php-client: Cannot handle token prior to 2017-11-11T07:03:06+0000","line":127,"exception":"Firebase\\JWT\\BeforeValidException","file":"\/var\/www\/html\/projectName\/vendor\/firebase\/php-jwt\/src\/JWT.php"

Created on 17 Nov 2017  路  2Comments  路  Source: googleapis/google-api-php-client

Error comes on server.

This issue does not come on a local server, but when I will run this code on the server I will get an error every first time.

Here is my code and error message :

Message : Cannot handle token prior,"exception":"Firebase\JWT\BeforeValidException"

 $client = new Google_Client(['client_id' => env('GOOGLE_CLIENT_ID')]);
 $googlePayload = $client->verifyIdToken($token);

Thank you!

p1 bug

Most helpful comment

You probably have a slight skew between the clock on the server that mints the tokens and the clock on the server that's validating the token - if the iat or nbf is in the future, then the token isn't yet valid.

One solution would be to use a small leeway, like this:

JWT::$leeway = 5; // Allows a 5 second tolerance on timing checks

All 2 comments

You probably have a slight skew between the clock on the server that mints the tokens and the clock on the server that's validating the token - if the iat or nbf is in the future, then the token isn't yet valid.

One solution would be to use a small leeway, like this:

JWT::$leeway = 5; // Allows a 5 second tolerance on timing checks

Duplicate of #1172

Was this page helpful?
0 / 5 - 0 ratings

Related issues

usamamashkoor picture usamamashkoor  路  5Comments

Fredyy90 picture Fredyy90  路  3Comments

mevsme picture mevsme  路  4Comments

whatido1 picture whatido1  路  3Comments

bencromwell picture bencromwell  路  3Comments