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

icsbcn's avatar

How to config sanctum laravel

Hello!

I'm trying to use Sanctum Laravel in my local server but I can't call my authenticated routes :(

My code is here:

Register and Login no problem but when I try to call to authenticated route (http://www.test_sanctum.local/index.php/api/user) with the Bearer Token i see :

{ "message": "Unauthenticated." }

Could you help me?

Thank you so much!

0 likes
9 replies
Sinnbeck's avatar

Why do you have index.php in the url? That should not be needed :)

icsbcn's avatar

@Sinnbeck Hello! Thank you for your response! If i delete index.php, I see error "404 Not Found". In this case, my local server configuration seems to need index.php in the url.

OussamaMater's avatar

And also maybe share the curl request with bearer token?

1 like
OussamaMater's avatar
Level 37

@icsbcn okay try running php artisan serve and in your postman make the same request but without the index.php it should work just fine

curl 
--location --request GET 'http://www.test_sanctum.local/api/user' 
--header 'Accept: application/json' 
--header 'Authorization: Bearer 1|VhsBv0vjZa5EfbPqR61YSaEFqjjfg426SUK9ROry'
1 like

Please or to participate in this conversation.