Reputation: 352
I am making an authentication api with Django, JWT and Laravel 5.1. But i don't know how to set expire time for token and how to send it to API from Client (make by Laravel 5.1 too). Can anyone help me, i know it is a basic question but i was tried to google but don't have any answer.
Thanks.
Upvotes: 2
Views: 3321
Reputation: 3170
Change the value of
'ttl' => 60, //Defaults to 1 hour
in your project /config/jwt.php
This is in Laravel 5.2 & JWT 0.5.
Upvotes: 2
Reputation: 5406
JWT supports a number of reserved claims. One of these is "exp". You encode a claim with this name and a timestamp as the value:
$key = "example_key";
$token = array(
"sample_key" => "sample_value",
"exp" => 1356999524, // expiration timestamp
);
$jwt = JWT::encode($token, $key);
Further reading: https://www.rfc-editor.org/rfc/rfc7519
Upvotes: 2
Reputation: 1438
As far as I know, jwt tokens are used for ajax requests and api development. If you are using laravel blades for your client side, then you don't need to use jwt. Laravel has a built in services for CSRF tokens and authentication.
laravel.com/docs/master/routing#csrf-protection
But you still need to use jwt, read this tutorial:
Token-Based Authentication for AngularJS and Laravel Apps
Upvotes: 0