0

I am trying to do authentication in framework7 with capacitorJS and Vue using Laravel Sanctum (and Fortify) as the API to authenticate the user. For the API calls I have used axios, capacitor-community-http and framework7 request/ajax. I don't get any errors related to CORS but I can't seem to get past the 'CSRF token is not valid' error, for some reason is not sending the cookies and therefore no CSRF token received by the API. I must say that using axios I can get it to work on web but IOS and Android do not work for me.

To clarify, I am trying to get the cookies based authentication or SPA authentication (https://laravel.com/docs/9.x/sanctum#spa-authentication) and not the token authentication or mobile application authentication (https://laravel.com/docs/9.x/sanctum#mobile-application-authentication).

I have created the project using framework7 cli and the API using Laravel documentation so there isn't any other files apart from the defaults that come when creating a fresh project. As I said before I've used capacitor-community-http and installed it through npm as well as axios through npm as well. Everything is in localhost.

Can anyone that have used capacitor with Laravel sanctum for authentication on IOS and Android let me know what they used or how they did it?

Thanks.

diegoanso
  • 1
  • 1
  • 1
  • Were you ever able to get this authentication scheme working? – BillPull Apr 27 '22 at 17:28
  • I have not being able to get this working. I had to use the token based authentication and save it on the phone using secure storage. – diegoanso Apr 29 '22 at 04:52
  • I was able to get cookie auth working against a Django backend https://stackoverflow.com/questions/72045698/capacitor-ios-using-cookie-based-auth – BillPull May 02 '22 at 14:16

0 Answers0