laravel/sanctum rest api token authorization failure with private token

28 Views Asked by At

I created a sanctum personal token, but it will not authorize rest API call.

I am using bearer token in header 'Authorization' but will still redirect to login.

Creating token works fine: http://localhost/api/sanctum/token

returns

2|hMASkhdQOzl7aOEL7G0At5A3yLZ0yWSLYNRy2kM7

am I supposed to use this output as a token?

Bearer hMASkhdQOzl7aOEL7G0At5A3yLZ0yWSLYNRy2kM7

Route::middleware('auth:sanctum')->post('/deals', [DealController::class, 'create' ]);
1

There are 1 best solutions below

2
Hilmi Hidayat On

You must access it by including the bearer token in the header like this:

enter image description here