I have my api with dingo/laravel. Normally works without problems for mobile (android).
My AuthController@token in dingo/laravel:
public function tokenRefresh()
{
$token = JWTAuth::getToken(); // Header:Auth..Baerer ...
if (!$token) {
throw new BadRequestHttpException('Token not provided');
}
try {
$token = JWTAuth::refresh($token);
} catch (TokenInvalidException $e) {
throw new AccessDeniedHttpException('The token is invalid');
}
return $this->response->withArray(['token' => $token]);
}
i making another app with nw.js, and i use it requestify module. My example login request:
requestify.request(this.authUrl, {
method : 'POST',
body : {
email: document.getElementById('email').value,
password: document.getElementById('password').value
},
headers : {
'X-Forwarded-By': 'me'
},
dataType: 'json'
}).then(function (response) {
var body = response.getBody();
alert(body.token);
});
its request normally return valid token. its ok.
How about expires token? What should I do? Maybe, kind of like ajaxSetup for all request before. I need to automatic refresh token when token expires. What do you recommend?