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
userswhereapi_token=
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', 
    ], 
],
                        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();
});
                        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