dongliang1865 2015-11-03 10:21
浏览 103
已采纳

BulletPHP框架和Firebase / JWT - 检查令牌错误

I am developing a REST API with BuletPHP framework. The fact is I have an angular JS app which stores locally the JWT token and sends to the server for checking expiration data. I have generated a token and I want to be rejected, but when I check the response It launches this exception:

exception 'Firebase\JWT\BeforeValidException' with message 'Cannot handle token prior to 2015-11-04T18:40:33+0100' in C:\Server\www\vendor\firebase\php-jwt\src\JWT.php:103 Stack trace: #0 C:\Server\wwwoutes\user.php(92): Firebase\JWT\JWT::decode('eyJ0eXAiOiJKV1Q...', 'QWRhZ2FsIFNpc3R...', Array) #1 [internal function]: Closure->{closure}(Object(Bullet\Request)) #2 C:\Server\www\vendor\vlucas\bulletphp\src\Bullet\App.php(311): call_user_func(Object(Closure), Object(Bullet\Request)) #3 C:\Server\www\vendor\vlucas\bulletphp\src\Bullet\App.php(195): Bullet\App->_runPath('GET', 'eyJ0eXAiOiJKV1Q...') 

Why I am getting this exception on token decoding function?

This is my token:

eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpZCI6IjAyMjAxNTExNjVkMmVhMDM0MjU4ODdhNzE3YzQzNTA4MWNmYzVkYmIxMzMwNjQwIiwibmFtZSI6InJvb3QiLCJpYXQiOjE0NDY0ODYwMzMsIm5iZiI6MTQ0NjY1ODgzM30.qHMee39xJC9Rgx4AUzJSkBUnK3P5R1BTjL_JA5j_6f5L99U-gzZkB4VM0LWrfIMOBFQWFC9lwlUNFPWnwPUiYQ 
  • 写回答

1条回答 默认 最新

  • douhao2011 2015-11-16 19:32
    关注

    This is happening because the time on your local machine/ local server is slightly slower than the remote server(wherever the token is being generated from) time.

    If you modify line 113 of vendor\firebase\php-jwt\src\JWT.php with the following debug you can see the output:

    echo '<br /> payload->iat = '. $payload->iat . '<br />and time() = '.time() . "<br />leeway= ". self::$leeway;
    

    This will output something similar to:

    payload->iat = 1447702275  
    and time() = 1447702211  
    leeway= 0
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化
  • ¥15 Mirare PLUS 进行密钥认证?(详解)
  • ¥15 物体双站RCS和其组成阵列后的双站RCS关系验证
  • ¥20 想用ollama做一个自己的AI数据库
  • ¥15 关于qualoth编辑及缝合服装领子的问题解决方案探寻
  • ¥15 请问怎么才能复现这样的图呀