Using custom id (api_account_id) instead of conventional user_id problem on laravel passport

  laravel, laravel-passport, php

I’m currently having trouble getting Laravel Passport setup. In my case, I didnt use User as my model, instead I have ApiAccount. So when laravel passport added the oauth migrations, I changed all of mentions of user_id to api_account_id. Now i am having trouble adding a personal access client from running php artisan passport:install. The error said that they can’t find user_id column. Is there a work around for this problem?

The error

SQLSTATE[42S22]: Column not found: 1054 Unknown column 'user_id' in 'field list' (SQL: insert into `oauth_clients` (`user_id`, `name`, `secret`, `redirect`, `personal_access_client`, `password_client`, `revoked`, `updated_at`, `created_at`)

Here’s my oauth migration table:

    public function up()
    Schema::create('oauth_clients', function (Blueprint $table) {
        $table->string('secret', 100);

ApiAccount model

class ApiAccount extends Authenticatable
    use SoftDeletes;

    use Notifiable, HasApiTokens;

and lastly my auth.php

    'guards' => [
    'web' => [
        'driver' => 'session',
        'provider' => 'users',

    'api' => [
        'driver' => 'passport',
        'provider' => 'api_accounts',
        'hash' => false,

'providers' => [
    'users' => [
        'driver' => 'eloquent',
        'model' => AppPartner::class,
    'api_accounts' => [
        'driver' => 'eloquent',
        'model' => AppApiAccount::class,

Source: Laravel

Leave a Reply