Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

rohanprajapati's avatar

Laravel Sanctum API not responds if the token is empty

So Basically i'm doing Multi Auth using Sanctum API but the problem is, if the token is valid then it gives the access and if the token is empty then it not responds, it should response as the token is invalid or somewhat unauthenticated user

0 likes
3 replies
vincent15000's avatar

@rohanprajapati When you perform login, so you mean the token for the session authentification ?

Is it this step ?

axios.get('/sanctum/csrf-cookie').then(response => {
    // Login...
});

https://laravel.com/docs/9.x/sanctum#spa-authenticating

Because for this step, you receive no response from the server. It just sets a CSRF token to be able to query the API and only then you can use the login endpoint to authenticate.

Please or to participate in this conversation.