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

Abdul Fattah Boshi
  • 333
  • 1
  • 4
  • 18
allready4v
  • 163
  • 1
  • 3
  • 8

2 Answers2

31

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

Jānis Elmeris
  • 1,975
  • 1
  • 25
  • 43
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
IlGala
  • 3,331
  • 4
  • 35
  • 49