0

I am new to Symfony and jwt Authentication.

I tried to set up an access to api platform resources with a jwt token.

I followed the doc https://symfony.com/bundles/LexikJWTAuthenticationBundle/current/index.html to set up the token.

My problem comes after the token generation, on PostMan I add the generated token in Authorization -> Type : Bearer Token -> Token: the token, and when I make the request I get a return:

{ "code": 401, "message": "Invalid JWT Token" } Token generation: enter image description here

Token info: enter image description here Request get/Users: enter image description here Security.yaml enter image description here

Thanks in advance for your help

Kawick
  • 31
  • 7
  • https://github.com/lexik/LexikJWTAuthenticationBundle/issues/736 – W.S. Sep 08 '22 at 13:01
  • my login is not a problem jwt does generate a token for me, the problem comes after when I want to use the token to make requests. – Kawick Sep 08 '22 at 13:26
  • Good to see you found the solution in the referred github issue anyway. – W.S. Sep 08 '22 at 14:16

1 Answers1

1

I found the problem

To connect I use the email field, while LexitJWT uses the username. I don't know why it doesn't block me from generating the token. To fix the problem just go to the config/packages/lexik_jwt_authentication.yaml file and add user_identity_field: email

enter image description here

Kawick
  • 31
  • 7