Open kswro opened 1 year ago
Unable to produce the issue in the latest stable 3.4.0-3 for local testing . Both the Authorization header and apiToken query param works fine .
@kswro I see that you are using insomnia api client app for testing and same for me . see the screenshot below
do you see any error in the error log file ?
Hello @touhidurabir
Thank you for your reply. I didn't find any error logs on PHP and Apache.
However, I have found a solution to this problem. From this page I learned that various Apache modules will strip the Authorization header, usually for "security reasons".
So, based on the same source, I added the line below to the .htaccess file in my OJS public folder and now I can connect to the REST API via authorization header:
CGIPassAuth on
Apart from the above lines, I also tried using other alternatives as below which also solved the problem.
RewriteEngine On
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule .* - [e=HTTP_AUTHORIZATION:%1]
Based on what I experienced (and many others), do you think the above problems and solutions can be added to the documentation?
FYI, I'm using Apache >2.4.54 and PHP 8.2 (FPM) in this test.
@kswro I will discuss with other dev team members to see if it is possible to add few details regarding this in the doc .
You should really add this note because i also experienced the same problem. If i didn't find this post i'd be spending a lot of time investigating what's going on. GG @kswro.
PRs for review:
@ewhanson are you the best person to review/merge this change to the API docs? I can also make the PR to the docs hub once approved.
Here's a screenshot of the change in my IDE's preview tool for easier review, where I've added the "Connection Issues" section:
Describe the bug I am unable to authenticate to the REST API via the Authorization Header as in the page https://docs.pkp.sfu.ca/dev/api/ojs/3.4#tag/Authentication (403 Forbidden).
But, if authentication uses the apiToken parameter query, the connection to the REST API can be established (200 OK).
To Reproduce Steps to reproduce the behavior:
What application are you using? OJS 3.4.0-3
Additional information Tested on production server and new (fresh) local installation.