Reputation: 290
I am trying to authenticate our user using the API token,
Here is my code config/auth.php
code
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'token',
'provider' => 'users',
],
],
My Api.php
is like this
Route::group(['middleware' => ['subdomain_setup','auth::api'],'prefix'=>'v1'], function () {
Route::get('getCoupons','Api\CouponAPI@getCoupons');
});
Now I am getting this error while accessing my api URL
Column not found: 1054 Unknown column 'api_token' in 'where clause' (SQL: select * from
users
whereapi_token
=
Upvotes: 5
Views: 11736
Reputation: 450
Clear the cache :
Clear Application Cache Run the following command to clear application cache of the Laravel application.
php artisan cache:clear
Clear config cache You can use config:clear to clear the config cache of the Laravel application.
php artisan config:clear
Upvotes: 1
Reputation: 146
Make sure you have run Passport migration and ['guards']['api']['driver']
set to passport in config/auth.php
, and updated the configuration cache
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',
'provider' => 'users',
],
],
Upvotes: 14
Reputation: 37
You must alter table to add a 'api_token' field.
Schema::create('users', function (Blueprint $table) {
$table->increments('id');
$table->string('name');
$table->string('email')->unique();
$table->string('password');
//Add api_token field
$table->string('api_token', 60)->unique();
$table->rememberToken();
$table->timestamps();
});
Upvotes: 2