tymondesigns / jwt-auth

🔐 JSON Web Token Authentication for Laravel & Lumen
https://jwt-auth.com
MIT License
11.27k stars 1.55k forks source link

Token refresh issue #1463

Open njofce opened 6 years ago

njofce commented 6 years ago

I am using the following method to refresh JWT token. Testing it from Postman returns "Token has been blacklisted" message. Any suggestion why this is happening.

Thanks

` public function refreshToken(){ $token = JWTAuth::getToken();

    if (! $token) {
        return response()->json('', 404);
    }

    try {
        JWTAuth::invalidate($token);
        $token = $this->manager->refresh($token)->get();
    } catch (TokenInvalidException $e) {
        return response()->json($e->getMessage(), 500);
    }

    return response()->json(compact('token'));

}`
chetannn commented 6 years ago

I am too facing the problem with refresh token to authenticate my react native app.

MithrandirDK commented 6 years ago

JWTAuth::invalidate($token);

doesn't that blacklist the token?

try with

[preceding code...]
try {
  $newToken = $this->manager->refresh($token)->get();
  JWTAuth::invalidate($token);
  $token = $newToken;
} catch (TokenInvalidException $e) {
    return response()->json($e->getMessage(), 500);
}
[.. remaining code]
njofce commented 6 years ago

@MithrandirDK I tried that as well and nothing changed.