JWTRefreshTokenBundle icon indicating copy to clipboard operation
JWTRefreshTokenBundle copied to clipboard

Lexik JWT custom endpoint

Open syntaxgirl opened this issue 3 years ago • 2 comments

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.

syntaxgirl avatar Jul 04 '21 14:07 syntaxgirl

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?

syntaxgirl avatar Jul 04 '21 20:07 syntaxgirl

I think you can use this #270 to manual generate a refresh token?

fd6130 avatar Aug 04 '21 08:08 fd6130