1

I'm using UserFrosting to manage users with PHP, in my API and I want to use the login function in controller with POST method.

When i call the login function it return me as response

The CSRF code was invalid or not provided.

I still cannot get the csrf_token

Any idea?

alexw
  • 8,468
  • 6
  • 54
  • 86
M. Hanafi
  • 66
  • 1
  • 11

2 Answers2

0

If you're developing an API (either for it to be consumed by an webplatform or mobile app) I belive it's better to have a different kind of authentication, namely, JWT authentication. In Laravel you have Passport to handle this Authentication with ease. I'm not sure how userFroasting uses laravel but if laravel version is above 5.3 you can use it.

If it isn't there's always the option of making a costum JWT authentication.

Here is the latest documentation for Passport https://laravel.com/docs/5.5/passport.

Sérgio Reis
  • 2,483
  • 2
  • 19
  • 32
  • 1
    i choose to work with userFrosting cause it's complete application user-admin. so BackOffice and Frontoffice already done! – M. Hanafi Sep 27 '17 at 13:53
0

There is a UserFrosting Sprinkle that implements JWT authentication: https://github.com/x00x70/tokeniser

Join us in chat if you have any questions about its use!

alexw
  • 8,468
  • 6
  • 54
  • 86