dsfdsf23423 2016-01-26 05:39
浏览 65

JWT Token Expiry不一致

I'm still new to laravel, api, as well as JWT. Is there anyone using tymon jwt?

I have been troubling with the Token Expiry. When ever it gets expired, it shows 2 different kinds of errors. Usually, it is just plainly {message: "token_expired"} with a status code of 401, which is fine. But, sometimes it shows up this kind of error, wherein it says it comes from a PayloadValidator, and which I could not trap where I can trigger this. It is a problem for me because its status code is 500 and our frontend developers do not want status code 500.

I would like to make it 400, or rather just have a consistent error response Is there anyone here could help me understand why there 2 kinds of error? How were these encountered?

Occurrence #1: Returns "Status 401 Unauthorized"

{
    "error": "token_expired"
}

Occurrence #2: Returns "Status 500 Internal Server Error"

{
    "message": "Token has expired",
    "status_code": 500,
    "debug": {
    "line": 74,
    "file": "C:\xampp\htdocs\laravel-project\vendor\tymon\jwt-auth\src\Validators\PayloadValidator.php",
    "class": "Tymon\JWTAuth\Exceptions\TokenExpiredException",
    "trace": [
    "#0 C:\xampp\htdocs\laravel-project\vendor\tymon\jwt-auth\src\Validators\PayloadValidator.php(32): Tymon\JWTAuth\Validators\PayloadValidator->validateTimestamps(Array)",
    ....
}

Inconsistent TokenExpiry Response

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥30 这是哪个作者做的宝宝起名网站
    • ¥60 版本过低apk如何修改可以兼容新的安卓系统
    • ¥25 由IPR导致的DRIVER_POWER_STATE_FAILURE蓝屏
    • ¥50 有数据,怎么建立模型求影响全要素生产率的因素
    • ¥50 有数据,怎么用matlab求全要素生产率
    • ¥15 TI的insta-spin例程
    • ¥15 完成下列问题完成下列问题
    • ¥15 C#算法问题, 不知道怎么处理这个数据的转换
    • ¥15 YoloV5 第三方库的版本对照问题
    • ¥15 请完成下列相关问题!