首页 > 解决方案 > 如何扩展jwt时间?Jwt 版本:“tymon/jwt-auth”:“^1.0.0-rc.2”Laravel 5.7

问题描述

如何延长令牌的期限?我的功能已过期,但无法正常工作。

    protected function respondWithToken($token)
    {
        return response()->json([
            'token' => $token,
            'token_type' => 'bearer',
            'expires_in' => auth()->factory()->getTTL() * 464465353454316000,
            'user' => auth()->user()
        ]);
    }
}

令牌很快过期。

'expires_in' => auth()->factory()->getTTL() * 464465353454316000 //this line not work property. Token expired early

标签: phplaraveljwttoken

解决方案


试试这个,它对我有用:

use JWTAuth;
...
            'expires_in' => JWTAuth::factory()->getTTL() * 24,

推荐阅读