You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello, I tried sanctum for my api authentication, but after many hours of trying I still cant figure out. I have two user provider, one for api and one for admin. Previously I used passport for my admin users, but decided to give sanctum a shot. Heres my configurations
This login is working, And I can see the cookies are returned(laravel_sessions, XSRF-TOKEN, and a token) but once I tried to call the protected routes, example /admin/V1/showcustomers,it always 401, and I can confirm that the requests headers contains those three, I dont understand why I always got 401. The frontend that calling the api is in the same project folder with the api, and its located inside /resources.js. The frontend(which houses the admin dashboard) is in laravel.test/admin, since the base url laravel.test is configured to redirect to laravel.test/admin and the api is in the laravel.test/admin/V1.I also noticed that the cookie contains weird string in the end ..longstringYWQzMzkifQ%3D%3D instead of ...longstringYWQzMzkifQ==
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Hello, I tried sanctum for my api authentication, but after many hours of trying I still cant figure out. I have two user provider, one for api and one for admin. Previously I used passport for my admin users, but decided to give sanctum a shot. Heres my configurations
auth.php
`
cors.php
admin.php / my custom route
sanctum.php
.env
I am using fetch to call login route
This login is working, And I can see the cookies are returned(laravel_sessions, XSRF-TOKEN, and a token) but once I tried to call the protected routes, example /admin/V1/showcustomers,it always 401, and I can confirm that the requests headers contains those three, I dont understand why I always got 401. The frontend that calling the api is in the same project folder with the api, and its located inside /resources.js. The frontend(which houses the admin dashboard) is in laravel.test/admin, since the base url laravel.test is configured to redirect to laravel.test/admin and the api is in the laravel.test/admin/V1.I also noticed that the cookie contains weird string in the end ..longstringYWQzMzkifQ%3D%3D instead of ...longstringYWQzMzkifQ==
Any ideas ?
Beta Was this translation helpful? Give feedback.
All reactions