Woocommerce rest api authentication issues

817 Views Asked by At

Even after setting up the REST API WooCommerce, you still get the following when performing an authenticated request:

{"code":"woocommerce_rest_cannot_view","message":"Sorry, you cannot list resources.","data":{"status":401}}

2

There are 2 best solutions below

0
On

The Authorization header is not being passed to PHP. Add the following to your .htaccess file at the top.

Needed for WooCommerce API

RewriteRule ^index.php$ - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization},L]

0
On

Try with below method

https://example.com/wp-json/wc/v3/products?consumer_key=XXXXXXX&consumer_secret=XXXXXX

The key is query_string_auth: true you need to force basic authentication as query string true under HTTPS