allready4v
allready4v

Reputation: 162

Laravel 5.3 integrate dingo api and oauth2 Column not found: 1054 Unknown column 'api_token' in 'where clause'

I'm using laravel 5.3 to build api and backend management for mobile app. I'm integrated Dingo/api package and use Oauth2 for authenticate. I made an API and login with postman: API url: mydomain/api/auth/login Logged in result:

{ "meta": { "message": "Success", "status_code": 1000, "status": true }, "data": { "access_token": "BK81coQ8mnR7PrfEuYzOwKBuZukXgeVw2pcUjHcZ", "token_type": "Bearer", "expires_in": 604800, "refresh_token": "KRIB6YnvqT25rG1fGtoMrK9mGeB7m2J3cdj9QB8N", "profile": { "id": 1, "user_id": 1, "name": "ThanhDN", "postal_code": null, "phone_number": null, "age": null, "gender": null, "address": null, "avatar": null, "status": null, "created_at": "2017-01-11 04:44:33", "updated_at": "2017-01-11 04:44:33", "deleted_at": null } } }

I used access_token to call API for get user information API url: mydomain/api/user/1 But I got an error:

{"message":"SQLSTATE[42S22]: Column not found: 1054 Unknown column 'api_token' in 'where clause' (SQL: select * from users where api_token = 9mQmZqIjqnRamzX7syjtU6X1jGWrfQXndKKT97TU limit 1)","code":"42S22","status_code":500,

I've searched but could not see any solution. Please help me resolve it. Thank you very much!!!

And even when you call logout url: mydomain/api/logout

Upvotes: 8

Views: 5050

Answers (2)

First of all run this command to refresh all the database migrations

php artisan migrate:refresh

and, after, run this command

php artisan passport:install

Upvotes: 0

Jānis Elmeris
Jānis Elmeris

Reputation: 2045

Make sure you have ['guards']['api']['driver'] set to passport in config/auth.php, and updated the configuration cache: php artisan config:cache.

Upvotes: 31

Related Questions