0
votes

I want to refresh my token for all Api. That code shows me error token invalid.i use jwt.refresh in my routes also but it can not refresh the token. it calls an API with same token in postman also. Here is my code.

public function logout()

{

    $token = (string)JWTAuth::getToken();

    $token = JWTAuth::setToken($token)->invalidate();

    $newToken = JWTAuth::refresh($token);

    return response()->json(['message'=>  $newToken]);
}

Here is my code of api.php

Route::post('maps/filter', [

'uses' => 'MapsController@filter',

'middleware' => ['jwt.auth', 'jwt.refresh']

]);

1
Do you catch update your token in front-end ? - Elnur Ibrahim-zade
I don't know about Front-end - Moaiz
Front end or Postman it does not matter. - Elnur Ibrahim-zade

1 Answers

0
votes

In the response's header you may find new token (Authorization token) next time you send request you should use updated one. So by each request you should update your token.