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

2

8

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

Premium answered 11/1, 2017 at 10:13 Comment(0)
C
31

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

Chest answered 6/2, 2017 at 19:8 Comment(2)
Ohhhhhhhhh, thank you daddy, just clearing of cache I needed. Spent over an house wondering what the heck i had done wrong. God bless you!!! +1Oshaughnessy
VERY NICEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEIntraatomic
A
0

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
Ankh answered 25/1, 2019 at 15:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.