Not sure how to help you.
Have you read this documentation ?
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
i'm building a SPA using Laravel API that should only allow login / register with some social accounts that are logged in via Socialite and that all works fine but i'm trying to combine Socialite + Sanctum (not sure if this the best approach or not) with the attempt to use SPA cookie based auth rather a bearer token.
Previously i used JWT and that worked fine but i'm trying to move to a cookie based approach as recommended then for mobile Sanctum supports the bearer tokens also.
Initially the SPA it calls "sanctum/csrf-cookie" route before a login (post), get's cookies and saves them in the browser - took me a while to configure this and get it actually working as i kept getting CSRF token mis match but that's fixed now.
Now when i make new requests i can see the the X-XSRF-TOKEN and XSRF-TOKEN cookies set in chrome.
Next i try to call a login endpoint that executes the code below to temp replace the social login code
Auth::loginUsingId(1, true);
return response()->json(Auth::user(), 200);
I can see the XSRF cookie set as a header in chrome
Cookie: XSRF-TOKEN= etc
But i don't see anything come back in the response regarding headers or cookies to indicate this user was logged in.
Then , when i call a protected API endpoint next it get
401 Unauthorized
I was under the impression that Sanctum using stateful auth, uses a cookie to maintain the session rather then having to use the bearer token and use Sanctum in stateless mode?
Therefor if i log in programmatically it should still return whatever is needed to use this in the client?
Any one know what i am missing?
Please or to participate in this conversation.