package: Sanctum
After generate token when request for get data its throw me error like this
Illuminate\Database\QueryException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'api_token' in
'where clause' (SQL: select * from `users` where `api_token` = XAzuNGUeOJ8CXbIoGEWhBTtWIFr0lFr8jjwScXQ4B0Qxfmu
2cHm9LaUwGX96zy0AnXhLLcCnBFCodQaOlimit 1) in file
go to config/auth.php
and change the api array in guards to sanctum example:
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'sanctum',
'provider' => 'users',
'hash' => false,
],
],
Go to routes/api.php
and use this
Route::middleware('auth:sanctum')->get('/user', function (Request $request) {
return $request->user();
});
instead of
Route::middleware('auth:api')->get('/user', function (Request $request) {
return $request->user();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With