I'm doing a program who can encode and decode a token with JWT method. My encode method works fine, but when i try to decode my token with an exp claim my program sent me this :
Fatal error: Uncaught Firebase\JWT\ExpiredException: Expired token in ..\Jwt Key\vendor\firebase\php-jwt\src\JWT.php:134***
My code :
$token2 = array(
"iss" => "example.org",
"aud" => "http://apigateway/api/oauth/token",
"exp" => 1340452126,
"iat" => 1340451826
);
$jwt = JWT::encode($token2, $privateKey, 'RS256');
echo "Encode:\n" . print_r($jwt, true) . "\n";
JWT::$leeway = 60; // $leeway in seconds
$decoded = JWT::decode($jwt, $publicKey, array('RS256'));
$decoded_array = (array) $decoded;
echo "Decode:\n" . print_r($decoded_array, true) . "\n";
I use a JWT library. The error takes me to the file JWT.php line 134 :
// Check if this token has expired.
if (isset($payload->exp) && ($timestamp - static::$leeway) >= $payload->exp) {
throw new ExpiredException('Expired token');
}
I search on the web and i can't find the one.. Thank you for your help !