0
votes

I'm setting up a refresh_token method with Laravel and jwt tymon library, i want to generate a new token after x minutes in my frontend application access. When i use the method that login a user by credentials, i receive the token but not receiving the refresh_token

I have already try to use refresh token methods but that thing just invalidate the first token and generate a new one.

/* Actual code that login user if credentials are valid and return valid token WITHOUT the refresh_token */

$credentials = request(['email', 'password']);   
if (!$token = auth()->attempt($credentials)) {
    return response()->json(['error' => 'Unauthorized'], 401);
}

/* my attempt to get a refresh_token to generate a new_one in future when token is expired */

$refresh_token = auth()->refresh($token);
return response()->json([
            'access_token' => $token,
            'refresh_token' => $refresh_token,
            'token_type'   => 'bearer',
            'expires_in'   => auth()->factory()->getTTL() * 60
            ]);
1

1 Answers

0
votes

I think it should be auth()->user->refresh()