'ttl' => null,
'refresh_ttl' => null,
I need the token does not expire.. It does not work, it always returns "error": "token expired"
'ttl' => null,
'refresh_ttl' => null,
I need the token does not expire.. It does not work, it always returns "error": "token expired"
In the file vendor/tymon/jwt-auth/config/config.php change the line
'ttl' => env('JWT_TTL', 60),
by the
'ttl' => env('JWT_TTL', null),
Also remove exp
in this line
'required_claims' => [
'iss',
'iat',
'exp',
'nbf',
'sub',
'jti',
],
Works for my
Steps for not expiring login in JWTAuth:
jwt.php
in config folder (if it not available then publish the jwt.php
file using this command in project==>php artisan vendor:publish --provider="Tymon\JWTAuthProviders\JWTAuthServiceProvider" )
'ttl' => env('JWT_TTL', 60),
to
'ttl' => env('JWT_TTL', null),
'required_claims' => [ 'iss', 'iat', 'exp', 'nbf', 'sub', 'jti', ],
This question is quite vague as we don't know which library/component is used to generate the Jot so we cannot know the way expiration claims are managed.
In general, to get a Jot that does not expire, such claims (exp
, ttl
or refresh_ttl
) should not be part of the payload.
The following token will expire in 3600 sec.
{
'iss': 'my-service'
'aud': 'your-service'
'sub': 'my-client'
'ttl': 3600
}
The following token should never expire.
{
'iss': 'my-service'
'aud': 'your-service'
'sub': 'my-client'
}
If you don't want to expire the token conditionally.
if ( // your condition ) {
$this->guard()->setTTL(null);
}