About this article: This article is reviewed against the cited sources. This is source research, not lab validation. Check the stated versions and your own requirements before making changes.
A WooCommerce REST API request that comes back with HTTP status 401, the code woocommerce_rest_cannot_view and the message "Sorry, you cannot list resources." reached WordPress with no signed-in user, so the permission check refused it. The first question is why the key did not sign it in. Work out why: the request used HTTP where HTTPS was expected, a proxy hides HTTPS from WordPress, the Authorization header was lost on the way, or the key is wrong, revoked or tied to a deleted user.
What the error means
In the WooCommerce 11.3.1 source, the list check for post-type endpoints returns this error when wc_rest_check_post_permissions() for the read context fails, which in wc-rest-functions.php means the current user lacks the post type's read_private_posts capability. The code is woocommerce_rest_cannot_view, the message is "Sorry, you cannot list resources." and the status comes from a WordPress function. The check for a single item uses the same code with the message "Sorry, you cannot view this resource."
WordPress documents that function, rest_authorization_required_code(), as returning "401 if the user is not logged in, 403 if the user is logged in." So a 401 with this code means the request ran with no signed-in user. A 403 would mean WordPress knew the user, and that user lacked the capability.
The WooCommerce documentation lists 401 Unauthorized as an authentication or permission error, such as incorrect API keys. Its authentication page describes two routes. Over HTTPS you send the consumer key as the username and the consumer secret as the password (HTTP Basic Auth). Over HTTP it says "You must use OAuth 1.0a" authentication. In the source, Basic Auth is only tried when WordPress's is_ssl() returns true.
The source also shows how a bad key behaves. A known key with the wrong secret gives a different error, "Consumer secret is invalid." An unknown consumer key sets no error at all. The request then carries on with no signed-in user and ends with the error in this title.
Likely causes
| Cause | What you see | How to confirm |
|---|---|---|
| Basic Auth credentials sent over HTTP | 401 woocommerce_rest_cannot_view on an http:// URL |
The same request works on the https:// address |
| A proxy or load balancer makes WordPress see HTTP | Fails on https:// too, header and query string alike |
WordPress's is_ssl() note names proxies and load balancers |
| The Authorization header is not passed to PHP | The key works as query-string parameters but not as a header | Query-string request succeeds |
| Wrong, revoked or unknown key, or the key's user was deleted | 401 (a key that does not sign a user in gives the 401), or "Consumer secret is invalid." | The key is missing from WooCommerce > Settings > Advanced > REST API |
| The key's user has no access to the resource | The REST API page lists this among its 401 advice; in the source a signed-in user gives 403 with the same code | Test with a key for an administrator |
Prove the cause before changing anything
Steps 1, 2 and 4 only read. Step 3 puts the consumer secret in a URL and has its own warning.
- Request the list with
-iso that the status line and the JSON body both show. The command form is the WooCommerce documentation's, with its-uoption for Basic Auth.
curl -i https://shop.example.com/wp-json/wc/v3/orders -u consumer_key:consumer_secret
A good result is HTTP 200 with a JSON list. A bad result is the JSON object with "code": "woocommerce_rest_cannot_view" and "status": 401 inside data. If the code is woocommerce_rest_authentication_error, read its message: "Consumer secret is invalid." points at the secret.
-
Note whether the integration calls an
http://or anhttps://address. A call that already useshttps://and still fails with this code points to the proxy cause or to the key. -
Pass the credentials as query-string parameters, the form the WooCommerce documentation gives for servers that do not parse the Authorization header.
Risk: the next request puts the consumer secret in the URL, not in the Authorization header. Use placeholder values to test the form; if you use the real secret, it is part of the address that was requested.
curl -i "https://shop.example.com/wp-json/wc/v3/orders?consumer_key=consumer_key&consumer_secret=consumer_secret"
- Open WooCommerce > Settings > Advanced > REST API and check that the key exists and which WordPress user it belongs to. The documentation says that "Use of the REST API with the generated keys will conform to that user's WordPress roles and capabilities" and that if the user is deleted, the key "will cease to function."
How to read the results: header fails and query string works, so the header is lost. Both fail on a correct https:// URL, so either WordPress does not see HTTPS or the key is wrong. Only http:// fails, so the request needs HTTPS or OAuth 1.0a.
Fix
Request made over HTTP
The change is made in the integration, not on the site. The alternative the documentation gives for plain HTTP is OAuth 1.0a signing, which a standard OAuth 1.0a library handles.
First save the current state: write down the address the integration now calls, and the time.
Risk: The next step makes the integration send the consumer key and secret to the https:// address only. A wrong address makes every call from the integration fail until the address is corrected.
Set the integration to call the https:// address with the same key, for example https://shop.example.com/wp-json/wc/v3/orders.
Only if you need to back out: set the address back to the one you wrote down. The integration then sends its requests over HTTP again and fails with this error. Then run the first request from the checks above to see the result.
A proxy hides HTTPS from WordPress
The WordPress is_ssl() page says sites behind some load balancers or reverse proxies that support HTTP_X_FORWARDED_PROTO can be fixed by adding code to wp-config.php, above the require_once call.
First save the current state:
cp -p wp-config.php wp-config.php.2026-12-04
Risk: The next edit changes wp-config.php, which every page of the site loads. A typing error can take the whole site down. The code makes WordPress treat any request that carries this header value as HTTPS.
Add the code from the WordPress is_ssl() page above the require_once line in wp-config.php:
if (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https')
$_SERVER['HTTPS'] = 'on';
Risk: the next command overwrites wp-config.php, so it also discards any other change made to the file since the copy.
To undo it: copy the saved file back over the edited one.
cp -p wp-config.php.2026-12-04 wp-config.php
Then request the site's home page to check that it loads.
Example (illustrative): the integration on app01 calls https://shop.example.com/wp-json/wc/v3/orders and gets 401 woocommerce_rest_cannot_view. The key is present for an administrator. The query-string request fails too. The shop sits behind a load balancer on web01 that terminates HTTPS. The administrator saves wp-config.php, adds the forwarded-protocol lines above the require_once line, and the same request returns 200.
The Authorization header is lost
The WooCommerce documentation says that if you see a "Consumer key is missing" error when authenticating over SSL, you have a server issue, and that you may then provide the key and secret as query-string parameters. It also tells you to check that authorization headers are properly read if your server uses FastCGI. The query-string form is a change in the integration, not in the site.
The key is wrong, revoked, or belongs to a user without access
The documentation's advice for 401 is to make a new set of keys and to choose a user who has access to the resources.
First save the current state: write down the consumer key and consumer secret the integration now holds (copy them from the integration's own settings), the key's description, user and permission level, and the time.
Risk: The next steps create a new credential that carries the chosen user's access to store data. The documentation says the secret is hidden if you try to view the key again, so copy it before you close the tab.
Go to WooCommerce > Settings > Advanced > REST API, click Add Key, give a description, choose the user, choose the permission level and click Generate API Key. Put the new key and secret into the integration.
To undo it, first put the consumer key and secret you wrote down back into the integration.
Then revoke the new key.
Risk: the next step revokes the new key with its Revoke API Key button, and anything that still uses that key stops working. Revoke it only once the integration is back on the old key.
Go to WooCommerce > Settings > Advanced > REST API, open the new key by its description and click Revoke API Key.
Confirm the fix
- Run the first request again. It returns HTTP 200 and a JSON list. The documentation says the total number of resources and pages are included in the
X-WP-TotalandX-WP-TotalPagesheaders. - Run the request with a key for a user who should have less access, and check that it returns only what that user's role allows.
- Load the site's front page and a checkout page, to be sure a
wp-config.phpedit broke nothing.
What to watch afterwards
- Send the consumer secret in the Authorization header, not in the URL.
- The WooCommerce documentation says that, since WooCommerce 11.3.1, a Store API request that sends a key is not run as the key's user, and that REST API keys do not authenticate requests to
/wp-json/wc/store/. Use the key on the REST API routes under/wp-json/wc/v3/, not on/wp-json/wc/store/. - After a key's user changes role, repeat the first request, since the key follows the user's capabilities.
- If the Site Health REST API test also fails, read WordPress Site Health "The REST API encountered an error": read the code, then find what blocks the request.
Read next
Related articles you may want next.
- HostingWordPress Site Health "The REST API encountered an error": read the code, then find what blocks the requestSite Health says The REST API encountered an error. Read the response line, test /wp-json/ from the server, then fix the network, rule or rewrite cause.Read article
- HostingWooCommerce "past-due actions found; something may be wrong": Action Scheduler is not running its queueWooCommerce shows Action Scheduler: N past-due actions found; something may be wrong. Test WP-Cron, check the runner, then clear the backlog with WP-CLI.Read article
- HostingWooCommerce classic checkout "There are no shipping options available.": zones, methods and the rules behind themWooCommerce classic checkout 'There are no shipping options available.': find the zone the address matches, check its methods and rules, then confirm.Read article
Risks and limits
- These commands have not been run or lab-tested.
- The error texts, codes and the HTTPS rule come from the WooCommerce 11.3.1 source; other versions may differ.
- Which headers a given proxy or FastCGI setup passes depends on the host's configuration, which is the hosting provider's to confirm.
- A key with the wrong secret and an unknown key produce different errors, as the source shows, so the message tells you which one you have.
Sources
- WooCommerce REST API — WooCommerce developer documentation, no date shown, accessed 4 December 2026
- Authentication — WooCommerce developer documentation, no date shown, accessed 4 December 2026
- class-wc-rest-posts-controller.php at tag 11.3.1 — WooCommerce source on GitHub, tag 11.3.1, no date shown, accessed 4 December 2026
- class-wc-rest-authentication.php at tag 11.3.1 — WooCommerce source on GitHub, tag 11.3.1, no date shown, accessed 4 December 2026
- curl man page — curl project, no date shown, accessed 4 December 2026
- cp — The Open Group Base Specifications Issue 7, 2018 edition (POSIX), accessed 4 December 2026
- wc-rest-functions.php at tag 11.3.1 — WooCommerce source on GitHub, tag 11.3.1, no date shown, accessed 4 December 2026
- rest_authorization_required_code() — WordPress Developer Resources, no date shown, accessed 4 December 2026
- is_ssl() — WordPress Developer Resources, no date shown, accessed 4 December 2026
This article was originally published on .