JWTRefreshTokenBundle
JWTRefreshTokenBundle copied to clipboard
Lexik JWT custom endpoint
Hi everyone. I am using api-platform with lexik jwt for tokens. I know that this bundle will generate a refresh token when using login_check. But how to use it with the custom endpoint (or api platform), when we are manually generating lexik jwt token?
I am using Data Persister to create jwt token.
I tried with
$response = new JsonResponse();
$event = new AuthenticationSuccessEvent(['token' => $token], $data, $response);
$this->dispatcher->dispatch($event, Events::AUTHENTICATION_SUCCESS);
Though I am not using $response
as Data Persister handles this on it's own. I tried dispatching event, thinking that this bundle will do the rest alone, but it doesnt work like that. Any tips?
I am basically using /api/users to create new user, and generating jwt token, returning it inside response. But I would like to return refresh token also. With the way from above, refresh token is generated properly.
I just found out that $event->getData();
will return token + refresh_token as array. I can use this, but I would like to know if maybe there is some better solution?
I think you can use this #270 to manual generate a refresh token?