Answer the question
In order to leave comments, you need to log in
How to refresh jwt token without user?
You need to update the token after the previous one is out of date.
I am using jwt-auth to generate a token in laravel.
As I understand it, to update the token in this library there is a Middleware that returns a new token in the http header.
I made the following router on the server:
Route::get('/refresh',['middleware' => ['jwt.auth','jwt.refresh'],'uses'=>'[email protected]']);
get('/api/admin/showusers?token=' + Auth.state.api_token)
.then((res) =>{
if(res.data.users){
this.users = res.data.users;
}
})
.catch((err) =>{
if(err.response.status == 401){
get('/api/refresh?token=' + Auth.state.api_token)
.then((res) =>{
console.log(res.response)
})
.catch((err) =>{
console.log(err.response)
})
}
})
}
}
Answer the question
In order to leave comments, you need to log in
You are trying to refresh using a token that is no longer valid, so it makes sense that you are not getting one. Accordingly, when your token flies to you, you first need to re-authorize and get a new token. Or do a refresh before the token becomes invalid.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question