LexikJWTAuthenticationBundle: "Bad credentials" after the first login_check

Hi,

I’m trying to use this Bundle with FOSUserBundle.

When I call /api/login_check, the JWT is generated, but if I do it a second call with the same username and the same password I have a :

{
    code: 401
    message: "Bad credentials"
}

And at every call to other api route I have a :

{
    code: 401
    message: "Invalid credentials"
}

I already use this bundle on an other app without FOSUser and it’s works fine.

Bad config ? Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 10 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

Use _username and _password as POST parameters. After some debuging, I found that those values are the default ones to use.

Hi, the probleme was : RewriteEngine On RewriteCond %{HTTP:Authorization} ^(.) RewriteRule . - [e=HTTP_AUTHORIZATION:%1] SHOULD BE in Virtualhost tag, NOT in Directory tag. thank you 😃

I had the same issue, the solution for me was json_login instead of form_login in security.yml

Don’t forget to enable the user after registration. I solved my problem like that.

I was struggling with the same issue for hours. I realized I didn’t setup apache virtual host correctly. So I added

    RewriteEngine On
    RewriteCond %{HTTP:Authorization} ^(.*)
    RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]

and it worked fine.

https://github.com/lexik/LexikJWTAuthenticationBundle/blob/master/Resources/doc/index.md#configuration