I get the error Error: Invalid signature - provided signature does not match [woocommerce_rest_authentication_error] when useinclude parameter, also I use per_page = 20
works fine when use 10 or lower items.
following code work fine.
$orders = $woocommerce->get('orders/', array(
'per_page' => 20,
'include' => array(554, 553, 550, 549, 548, 547, 546, 545, 544, 543)
));
If I extend one or more ids then I get the above mention error
$orders = $woocommerce->get('orders/', array(
'per_page' => 20,
'include' => array(554, 553, 550, 549, 548, 547, 546, 545, 544, 543, 542, 541)
));
I double check all order ids one by one all are correct, and also I debug by using individual id I get all orders using the following code
$orders = $woocommerce->get('orders/', array(
'per_page' => 20
));
I spent almost whole day with this issue. There is a little bug in WooCommerce PHP API Library.
To understand this bug you have to take a look at .../src/WooCommerce/HttpClient/OAuth.php:193
It sorts parameters (by key), but leaves out nested arrays, although
$this->getParameters()
uses$this->getSortedParameters()
, which is more advanced and sorts also nested arrays.So here's the problem: if
$parameters
has nested array with more than 9 elements,$parameters
differs from$this->getParameters()
and more importantly from signed string$stringToSign
, so OAuth throws an error: "Invalid signature - provided signature does not match. [woocommerce_rest_authentication_error]".Example:
$parameters
$this-getParameters();
It takes just one small change to solve this issue.
.../src/WooCommerce/HttpClient/OAuth.php:193
change to:
I also made a pull request: https://github.com/woocommerce/wc-api-php/pull/278