forked from luciferous/jwt
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Description
Hello,
I get this message: Fatal error: Uncaught exception 'Firebase\JWT\ExpiredException' with message 'Expired token' in /www/lalalal/jwtTest/JWT/JWT.php:134 Stack trace: #0 /www/lallal/jwtTest/index.php(63): Firebase\JWT\JWT::decode('eyJ0eXAiOiJKV1Q...', 'example_key', Array) #1 {main} thrown in /www/lalalla/jwtTest/JWT/JWT.php on line 134
Do I have to declare my own Exception? I'am using this code to provide an expired exp-date:
<?php
use \Firebase\JWT\JWT;
require 'JWT/JWT.php';
require 'JWT/BeforeValidException.php';
require 'JWT/ExpiredException.php';
require 'JWT/SignatureInvalidException.php';
$key = "example_key";
$token = array(
"iss" => "http://example.org/",
"aud" => "http://example.com/",
"iat" => 1356999524,
"nbf" => 1357000000,
"exp" => time()-1000
);
$jwt = JWT::encode($token, $key); //HS256 by default.
echo "jwt: ".$jwt;
echo $t."--------------------------".$t;
$decoded = JWT::decode($jwt, $key, array('HS256'));
My source-files are still downloaded (newest) and untouched. PHP Version ist 5.6.29
OK. I think I get it: To get use to it you have to wrap in try:
try {
$decoded = JWT::decode($jwt, $key, array('HS256'));
} catch (Exception $e) {
echo 'Exception catched: ', $e->getMessage(), "\n";
}
May be you shout add this to your example.
I'am beginner so are there other possibilities? And why are you defining your own Exception?
Metadata
Metadata
Assignees
Labels
No labels