Open DASAT opened 2 years ago
Add the following rule in your .htaccess file:
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
We actually added the following line into the Apache directives in PLESK Host-Setting for HTTP and HTTPS serving (from https://talk.plesk.com/threads/empty-authorization-header-on-php-with-nginx.358618/):
SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
This solved the issue of getting a
{
"code": "rest_forbidden",
"message": "You cannot view the post.",
"data": {
"status": 401
}
}
If you queried anything besides the root of the REST-API.
Hi, I installed the REST API and I tried to get a list of all posts - I can connect to the WordPress Installation but I can not authenticate. What do I do wrong?
I'm using the curl class https://github.com/dcai/curl - and it works fine with all other APIs I use.
Thank you all.
<?php
$authorization = 'Authorization: Bearer xxxxxxxxxxxx'; // API Key generated in the REST API Addon - Doesnt work // even if I try // $authorization = 'Authorization: Basic {base64("xxx:yyyyyyyy1")'; //Username and Password - Doesn't work
$url ="https://mydomain/wp-json/wpdm/v1/packages/";
//string(94) "{"code":"rest_forbidden","message":"You cannot view the post resource.","data":{"status":401}}" ?>