I have been having some issues, i am using This oauth library and at first I thought it had an error on it since i could get my tokens correctly but when consuming the tokens i got a 401 error, after some experimentation i found out that it has something to do with apache. If I start the php server from a command line it does work correctly, so now I am in a point where I have no idea what can apache be doing to make the scripts malfunction.
I have XAMPP installed on a windows machine. (Apache/2.4.27 (Win32) OpenSSL/1.0.2l PHP/7.1.9)
I have the virtualhost configured in apache, like this.
<VirtualHost *:80>
DocumentRoot “C:/xampp/htdocs/slim3-simple-rest-skeleton-master/public”
ServerName TestSite
and my etc hosts file added the line
127.0.0.1 TestSite
with that configuration i am able to make a request to http://testsite/oauth/token and get my access token, so here everything works just fine.
but when i go to http://testsite/books i get a blank page with 401 unauthorized header.
in the other hand, if i go to my folder slim3-simple-rest-skeleton-master
and run this
php -S 0.0.0.0:8888 -t public/
i can get my token at http://localhost:8888/oauth/token just as before, and when i do a get to http://localhost:8888/books it works correctly.
i had to comment out
if (PHP_SAPI === ‘cli-server’ && $_SERVER[‘SCRIPT_FILENAME’] !== FILE) {
return false;
}
in the app.php for this to work on php built-in server