I needed a token that will never expire i.e it will have a lifetime validity. So, I changed the following in jwt.php
file in config
folder.
'ttl' => env('JWT_TTL', null),
But after this action I started getting erros saying: TymonJWTAuthExceptionsTokenInvalidException: JWT payload does not contain the required claims in file apiTest/vendor/tymon/jwt-auth/src/Validators/PayloadValidator.php on line 65
.
2
Answers
This issue is occuring because
required_claims
is expecting theexp
. So just removeexp
key from yourconfig/jwt.php's
required_claims
array like.In my case I just commented the
exp
line and this will solve the problem.A issue was created on github regarding this issue. You can find it here. Here you will get solution to this problem and similar problems.
Steps for not expiring login in JWTAuth:
jwt.php
in config folder (if it not available then publish thejwt.php
file using this command in project==>php artisan vendor:publish --provider="TymonJWTAuthProvidersJWTAuthServiceProvider" )
'ttl' => env('JWT_TTL', 60),
to
'ttl' => env('JWT_TTL', null),
'required_claims' => [ 'iss', 'iat', 'exp', 'nbf', 'sub', 'jti', ],