Title: Rest api auth error
Last modified: January 16, 2024

---

# Rest api auth error

 *  Resolved [ggiggity](https://wordpress.org/support/users/ggiggity/)
 * (@ggiggity)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/rest-api-auth-error/)
 * HIi i’m building nextjs headless cms using wp and wc rest api
 * currently hosting from aws lightsail we migrated from siteground. There was no
   problem with data fetching, everything was working until i tried to test out 
   my headless cms.
 * i hosted another website with same domain and there was a lot of conflicts, i
   deleted the new hosted website immediately.
 * but ever since all the rest api data fetching returns 401 unauthorized “You can’t
   not list the resources”.
 * none of the authorization methods works.
 *  const WooCommerceRestApi =require(“@woocommerce/woocommerce-rest-api”).default;
 * export const api = new WooCommerceRestApi({
 * url:process.env.DB_WEB,
 *  consumerKey: process.env.DB_KEY,
 *  consumerSecret: process.env.DB_TOKEN,
 * version: “wc/v3”, });
 * doesn’t work passing em to headers even basic auth doesn’t work with username
   and password.
 * only some of them does work if i pass my consumer key and secret them into params
   I tried to fix it by making new website/ import back ups/ connect domain/ get
   fresh credentials, clear cache.i haven’t gotten any close to fixing it
 * “code”: “woocommerce_rest_cannot_view”,
 * “message”: “Sorry, you cannot list resources.”,
 *  “status”: 401

Viewing 1 replies (of 1 total)

 *  [ckadenge (woo-hc)](https://wordpress.org/support/users/ckadenge/)
 * (@ckadenge)
 * [2 years, 4 months ago](https://wordpress.org/support/topic/rest-api-auth-error/#post-17350629)
 * Hi there [@ggiggity](https://wordpress.org/support/users/ggiggity/), thank you
   for reaching out.
 * A 401 error indicates that you’re dealing with an authorization issue. The fact
   that it started happening after you hosted another website with the same domain
   suggests that there might be some leftover conflicts or settings that are causing
   this issue.
 * It is possible that the credentials you’ve supplied while trying to access the
   endpoint are wrong or invalid.
 * The most common reasons for this are:
    - You have the wrong API keys (Consumer Key & Consumer Secret)
    - You have the wrong permissions set on the keys
    - The permalink settings for the site are incorrect
 * I’d recommend taking a look at the WooCommerce REST API documentation here ad
   following the directions provided – [https://woocommerce.com/document/woocommerce-rest-api/](https://woocommerce.com/document/woocommerce-rest-api/)
 * The documentation here goes over how to properly work with the API, how to test
   it, and also provides some tips for sorting out 401 errors – [https://github.com/woocommerce/woocommerce/blob/trunk/docs/rest-api/getting-started.md](https://github.com/woocommerce/woocommerce/blob/trunk/docs/rest-api/getting-started.md)

Viewing 1 replies (of 1 total)

The topic ‘Rest api auth error’ is closed to new replies.

 * ![](https://ps.w.org/woocommerce/assets/icon.svg?rev=3234504)
 * [WooCommerce](https://wordpress.org/plugins/woocommerce/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woocommerce/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woocommerce/)
 * [Active Topics](https://wordpress.org/support/plugin/woocommerce/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woocommerce/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woocommerce/reviews/)

## Tags

 * [auth](https://wordpress.org/support/topic-tag/auth/)
 * [restapi](https://wordpress.org/support/topic-tag/restapi/)

 * 1 reply
 * 2 participants
 * Last reply from: [ckadenge (woo-hc)](https://wordpress.org/support/users/ckadenge/)
 * Last activity: [2 years, 4 months ago](https://wordpress.org/support/topic/rest-api-auth-error/#post-17350629)
 * Status: resolved