WooCommerce-REST-API-Client-Library
WooCommerce-REST-API-Client-Library copied to clipboard
WooCommerce-REST-API-Client-Library returns Invalid Signature .
Hello while using php WooCommerce rest api client library to get product data but i am getting this error
Invalid JSON returned for http://_http://www.nokhaeshope.in/wc-api/v2/products?oauth_consumer_key=ck_0fb05cfa41a8f0965005b2d0288182c388736abf&oauth_timestamp=1454658686&oauth_nonce=149dd552262c25b956d61967e96d9f3d018d3414&oauth_signature_method=HMAC-SHA256&oauth_signature=GUber0JU%2FRJvDBDcfCSzHvJMmQYX0agbSDLtRrC%2FSak%3D. 0 stdClass Object ( [headers] => Array ( [0] => Accept: application/json [1] => Content-Type: application/json [2] => User-Agent: WooCommerce API Client-PHP/2.0.1 ) [method] => GET [url] => http://_http://www.nokhaeshope.in/wc-api/v2/products?oauth_consumer_key=ck_0fb05cfa41a8f0965005b2d0288182c388736abf&oauth_timestamp=1454658686&oauth_nonce=149dd552262c25b956d61967e96d9f3d018d3414&oauth_signature_method=HMAC-SHA256&oauth_signature=GUber0JU%2FRJvDBDcfCSzHvJMmQYX0agbSDLtRrC%2FSak%3D [params] => Array ( [oauth_consumer_key] => ck_0fb05cfa41a8f0965005b2d0288182c388736abf [oauth_timestamp] => 1454658686 [oauth_nonce] => 149dd552262c25b956d61967e96d9f3d018d3414 [oauth_signature_method] => HMAC-SHA256 [oauth_signature] => GUber0JU/RJvDBDcfCSzHvJMmQYX0agbSDLtRrC/Sak= ) [data] => Array ( ) [body] => [duration] => 3.5082 ) stdClass Object ( [body] => [code] => 0 [headers] => Array ( ) )
I have cross checked my consumer key and secret both are valid.
when i click on these urls its giving me
{"errors":[{"code":"woocommerce_api_authentication_error","message":"Invalid Signature - provided signature does not match"}]}
I am having a similar problem with the signature showing incorrect and throwing a 401 error. I have resorted to using the supplied example.php and put in the auth. keys just to be sure. For reference I am talking to the server via putty and with the below command
php example.php
If I just use the print_r( $client->index->get() );
command, it works fine. BUT, if I try ANY other command such as print_r( $client->products->create( array( 'title' => 'Test Product', 'type' => 'simple', 'regular_price' => '9.99', 'description' => 'test' ) ) );
, it fails with the below information. All of these are in the example.php file.
I AM AT MY WITS END with this and there has been NO solution posted that even gets me close to solving the issue. I would GREATLY appreciate any thoughts that would get me closer to solving this pesky problem.
Thanks
Error: Invalid Signature - provided signature does not match [woocommerce_api_authentication_error]
401
stdClass Object
(
[headers] => Array
(
[0] => Accept: application/json
[1] => Content-Type: application/json
[2] => User-Agent: WooCommerce API Client-PHP/2.0.1
)
[method] => POST
[url] => http://serverurl.com/wc-api/v2/products?oauth_consumer_key={key removed}&oauth_timestamp=1456519814&oauth_nonce=b828d9c7a16f796b6dee2adccf22a20b02c81454&oauth_signature_method=HMAC-SHA256&oauth_signature={removed removed}
[params] => Array
(
[oauth_consumer_key] => {key removed}
[oauth_timestamp] => 1456519814
[oauth_nonce] => b828d9c7a16f796b6dee2adccf22a20b02c81454
[oauth_signature_method] => HMAC-SHA256
[oauth_signature] => +w7hg12Oq5YnVtwrScdbmPnlgtXR+2ZjhRLQCiRz6tU=
)
[data] => Array
(
[product] => Array
(
[title] => Test Product
[type] => simple
[regular_price] => 9.99
[description] => test
)
)
[body] => {"product":{"title":"Test Product","type":"simple","regular_price":"9.99","description":"test"}}
[duration] => 0.52562
)
stdClass Object
(
[body] => {"errors":[{"code":"woocommerce_api_authentication_error","message":"Invalid Signature - provided signature does not match"}]}
[code] => 401
[headers] => Array
(
[Date] => Fri, 26 Feb 2016 20:50:14 GMT
[Server] => Apache/2.4.18 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4
[X-Powered-By] => PHP/5.5.31
[Connection] => close
[Transfer-Encoding] => chunked
[Content-Type] => application/json; charset=UTF-8
)
)
Hello, After applying all permutations and combinations i came to conclusion that i was getting this error because i had plugin named "Word App" activated in my dashboard that was creating this problem which was blocking my rest API access so after deactivating the plugin everything started working fine.
so check if you have any such similar plugin that is causing issue. also can tell me are u able to retrieve products list.
I mean you are getting this error on (POST) creating product or also on (GET) retrieving product.
Thanks.
I checked and there are no apps that are running so that isn't the issue as much as I would like it to be that simple.
I mean you are getting this error on (POST) creating product or also on (GET) retrieving product.
To answer your question, I am getting the error on both. The only place I'm not getting the error is when I, using the same credentials and scripts, pull a parameters list. Both POST and GET fail no matter if it's product, orders, coupons, anything.
This is the only thing that works:(cut from example.php)
<?php
require_once( 'lib/woocommerce-api.php' );
$options = array(
'debug' => true,
'return_as_array' => false,
'validate_url' => false,
'timeout' => 30,
'ssl_verify' => false,
);
try {
$client = new WC_API_Client( 'http://your-store-url.com', 'ck_enter_your_consumer_key', 'cs_enter_your_consumer_secret', $options );
print_r( $client->custom->get( $params ) );
} catch ( WC_API_Client_Exception $e ) {
echo $e->getMessage() . PHP_EOL;
echo $e->getCode() . PHP_EOL;
if ( $e instanceof WC_API_Client_HTTP_Exception ) {
print_r( $e->get_request() );
print_r( $e->get_response() );
}
}
But if I substitute the print_r with ANYTHING else in the example.php such as:
print_r( $client->products->create( array( 'title' => 'Test Product', 'type' => 'simple', 'regular_price' => '9.99', 'description' => 'test' ) ) );
or
print_r( $client->customers->get() );
they fail.
Hello, I think the problem is with version of API because when I am using v3 version i m getting this error But for v2 same code is working fine.
I am currently using V2 code. Looking at maybe reloading the entire Woocommerce code to see if that fixes the issue.
sure...:)
What fixed the issue with me: turning off debug. (....................I know right... xD)
Hi @kg4nds, Have you found any solution? I'm running into exactly same issue.
See if you have confirmed your keys and code then the problem may be due to some external plugins as wordapp or any other security plugin.
For me, I found that there was a problem with the security cert for the domain name. Once that was resolved, the problem went away. I had been told that the security cert was good and installed every time I asked thus the reason I didn't look at that as an issue at first. I finally went in and found out differently and had to prove it to the site admin that they were wrong. Everything is working as needed. I now have other wonderful issues to deal with. :-)
@kg4nds, then maybe it's a little strange that all provided examples are with http. Thank you for the answer!
Have you found any solution? I'm running into exactly same issue.
When i apply this that working :-1: http://mercury.ourgoogle.in/projects/sendcart/wp-json/wc/v2/products?oauth_consumer_key=ck_56c0dedf3381c10743b15b7bcf222980d3c8eec8&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1492765313&oauth_nonce=2136752121&oauth_version=1.0&oauth_signature=3y7ZFbgj8vfMUCXzlBlmOXs3c7E=
But when i apply per_page its : - http://mercury.ourgoogle.in/projects/sendcart/wp-json/wc/v2/products?oauth_consumer_key=ck_56c0dedf3381c10743b15b7bcf222980d3c8eec8&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1492765313&oauth_nonce=2136752121&oauth_version=1.0&oauth_signature=3y7ZFbgj8vfMUCXzlBlmOXs3c7E=&per_page=15
that's response in :-{"code":"woocommerce_rest_authentication_error","message":"Invalid timestamp.","data":{"status":401}}
please help me.