DEV Community

Pavel Olnyov
Pavel Olnyov

Posted on

3 1

Laravel Passport don`t work. Error: column "api_token" does not exist

I want to create API with OAuth 2.0 authentication.

Use Laravel Passport tutorial https://laravel.com/docs/6.x/passport.

Set up the configuration on config/auth.php:

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

    'api' => [
        'driver' => 'passport',
        'provider' => 'users',
    ],
],
Enter fullscreen mode Exit fullscreen mode

When testing, I use a fresh token, but in response I get an error:

SQLSTATE[42703]: Undefined column: 7 ERROR:  column "api_token" does not exist↵LINE 1: select * from "users" where "api_token" = $1 limit 1
Enter fullscreen mode Exit fullscreen mode

Solution: clear the cache with command:

php artisan config:clear
Enter fullscreen mode Exit fullscreen mode

Top comments (3)

Collapse
 
lmadrid0289 profile image
Luis Madrid

ohh man I was struggling with that, all the basic answers were "change the driver" but php artisan config:clear was the deal yoooo!!! thanx!!

Collapse
 
olnyov profile image
Pavel Olnyov

Laravel 6.x Passport does not require adding the api_token column to the users table, there is no need to create a migration with adding the api_token column.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay