Jwt-auth: Is there a way to make dynamic JWT time to live ?

Created on 18 Oct 2016  路  7Comments  路  Source: tymondesigns/jwt-auth

Hello again, I would like to know if is there a way to make dynamic ttl in jwt. In my API I setted it to 300 minutes and works well, but I want to change it and set to null (infinite) just in my mobile app. So I will create a mobile auth endpoint, and just at this endpoint I want to set another ttl.
I know that I can change in config/jwt.php but it will change for all.

How could I do it ?

Most helpful comment

also now with the new version you can do something like
$token = auth()->setTTL(120)->login($user)

All 7 comments

Im having the same doubt.. any answers for this??

I could use this functionality too. Would be nice to be able to overwrite/set the attributes just before making the token perhaps?

// Overwrite jwt config settings, for this execution of php/laravel framework
JWTAuth::setTTL(60);

// Then create the token?
JWTAuth::
$token = JWTAuth::fromUser($customer);

Or is something like this already possible? I haven't been able to find it yet

Have you found the solution to this.

JWTAuth::factory()->setTTL($n);
JWTAuth::factory()->setRefreshTTL($m);

also now with the new version you can do something like
$token = auth()->setTTL(120)->login($user)

how work with 1.0.0-rc.1? @sleenen

@Insua haven't tried it yet, but I will soon work on implementing latest version when upgrading to L5.6

Was this page helpful?
0 / 5 - 0 ratings

Related issues

agneshoving picture agneshoving  路  3Comments

shah-newaz picture shah-newaz  路  3Comments

aofdev picture aofdev  路  3Comments

johncloud200 picture johncloud200  路  3Comments

therealmjk picture therealmjk  路  3Comments