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)",
....
}