Laravel 如何在ranm8/requestify中使用令牌刷新?
我有我的澳洲野狗/拉拉维尔的api。在移动设备(android)上正常工作没有问题 我的AuthController@token野狗/拉拉维尔:Laravel 如何在ranm8/requestify中使用令牌刷新?,laravel,node-webkit,nw.js,dingo-api,requestify,Laravel,Node Webkit,Nw.js,Dingo Api,Requestify,我有我的澳洲野狗/拉拉维尔的api。在移动设备(android)上正常工作没有问题 我的AuthController@token野狗/拉拉维尔: public function tokenRefresh() { $token = JWTAuth::getToken(); // Header:Auth..Baerer ... if (!$token) { throw new BadRequestHttpException('Token
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]);
}
我用nw.js制作了另一个应用程序,我使用它来创建requestify模块。
我的登录请求示例:
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);
});
其请求通常返回有效令牌。没关系
代币怎么样?
我该怎么办?
也许,有点像以前所有请求的ajaxSetup。
我需要在令牌过期时自动刷新令牌。
你推荐什么