Problem with API authentication on a production website
Hi, I was working on adding API authentication (password grant) to an already deployed laravel website and I've already done all the steps mentioned in the documentation in fact I already done the steps locally to test it and everything worked ass it should but on the website it keeps showing this response
{
"message": "Unauthenticated."
}
I spent a couple hours debugging with no luck. I tried generating new tokens, using * for scopes, checking all the steps again. thanks in advance
From your thread I guess you're using Passport. Are you sure you have everything configured correctly? Using the correct redirect url, using a new token etc?
@bobbybouwmann yes I'm using Passport, I did check the files multiple times and I can't see anything I'm missing and I requested a new token aswell with no luck.
@D9705996 Its Apache I think, do you know where and how I could do that I do have access to the cpanel
You should be able to add to an htaccess I just prefer in the virtual host. Can you provide details of the error from either apache logs or storage/logs/laravel.log as somethings blowing up in the backend
2018-10-06 09:58:38] production.ERROR: SQLSTATE[42S22]: Column not found: 1054 Unknown column 'api_token' in 'where clause' (SQL: select * from `users` where `api_token` = eyJ0eXAiOiJKV... limit 1) {"exception":"[object] (Illuminate\Database\QueryException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'api_token' in 'where clause' (SQL: select * from `users` where `api_token` = eyJ0eXAiOiJKV1... limit 1) at /home/visionar/visionarywritings/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664, PDOException(code: 42S22): SQLSTATE[42S22]: Column not found: 1054 Unknown column 'api_token' in 'where clause' at /home/visionar/visionarywritings/vendor/laravel/framework/src/Illuminate/Database/Connection.php:326)
[stacktrace]
This is the error on laravel.log when I add the lines to the .htaccess without restarting the server, if I remove them no error happens. I did trim the token as its too long
@D9705996 no I had no idea that's even needed its not mentioned anywhere and even in my local database where everything is working fine I can't see an api_token in the users table