Reputation: 229
Postman rertun this error
Illuminate\Database\QueryException: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'api_token' in 'where clause' (SQL: select * from
users
whereapi_token
= B6eJj892tHBKvX186BYZgmqqqG8Iz4npy85ArvJS80boCT4UYNBD5CGDIdG6Dm5nlSi83cY3n0XTvsxj andusers
.deleted_at
is null limit 1) in file /var/www/html/myapp/vendor/laravel/framework/src/Illuminate/Database/Connection.php on line 669
My column name in my table is token. I've also configured my storage_key in config/auth.php
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
'storage_key' => 'token',
'input_key' => 'token',
'hash' => false,
],
],
my ApiController.php has this code
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
class ApiController extends Controller
{
public function __Construct() {
$this->middleware('auth:api');
}
public function user(Request $request) {
return $request->user();
}
}
And my api.php has
Route::get('user', 'ApiController@user');
I am calling my api in this way http://localhost:8000/api/user?token=myGeneratedToken
Upvotes: 1
Views: 1601
Reputation: 229
If you are facing the same issue, then clear your cache by using this command
php artisan config:cache
and try again
Upvotes: 3