I've seen many posts about this error, but none of the solutions are working for me.
I'm running Laravel with Passport which is working fine on my development server. As expected, when attempting to check if a user is authenticated on my development server, it returns the catch (inside an axios call):
Development Server
"message":"Unauthenticated."
However, when running the same code on my production server, it returns the catch:
Production Server:
"message": "SQLSTATE[42S22]: Column not found: 1054 Unknown column 'api_token'
in 'where clause' (SQL: select * from `users` where `api_token` = ...
I have have run Passport migration and ['guards']['api']['driver'] set to passport in config/auth.php, and updated the configuration cache that apparently solved the problem for others.
It looks like authentication needs to use the oauth tables from passport migration, but the query appears to be looking at the user table.
EDIT:
I was able to determine that my development server uses the RequestGuard
class to find user and my production server uses the TokenGuard
class to find user.
I have faced the same problem. And I am using Laravel Passport. It all about configuration. got to config/auth.php
and change driver name of api array to passport within the guards array
'guards' => [
'web' => [
'driver' => 'session',
'provider' => 'users',
],
'api' => [
'driver' => 'passport',//instead of token
'provider' => 'users',
'hash' => false,
],
],
I was facing same problem and i have solve this by
php artisan config:clear
php artisan config:cache
php artisan cache:clear
may be it helpful
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