-
Notifications
You must be signed in to change notification settings - Fork 110
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Missing the X-WC-Store-API-Nonce header. This endpoint requires a valid nonce. #7
Comments
What is the endpoint being called? |
POST https://www.mysite.com/wp-json/wc/store/cart/items {"code":"woocommerce_rest_missing_nonce","message":"Missing the X-WC-Store-API-Nonce header. This endpoint requires a valid nonce.","data":{"status":401}} |
I can see this is a woo commerce error, but the cart management is not handled by woocommerce, as it has no means of handling that, so you should not be getting any woocommerce related error on cart. Which of the plugin's function was called? |
Hi, my issue is this : #2 |
Hi, nothing to do. It’s not work. I have the nonce key with the library that you have send me, I add on headers but now I receive invalid nonce. Did you have a sample code to fix this issue ? |
Hi. Pls share code. Adding to cart does not use woocommerce api. So a woocommerce auth error is unlikely. |
Hi I am sorry it's my bad, the solution is based on WooSignal extension on WooCommerce, which is a paid service, by using this service i got the nonce and send it to the method in WooCommerce api, but i am still looking to find something can help to fetch nonce from wordpress. btw all founded method used some javascript libraries for that, i cannot find the url to get the generated nonce. |
Is this issue resolved with new update? |
I m still getting |
Did anyone found the solution for this? |
Not yet sorry. We need nonce data from server. To achieve this i guess we must write a function to functions.php manually. |
I too stuck at this error :( |
It looks like the endpoint /wp-json/wc/store/cart/items does not exist. Is it possible to integrate with co-cart plugin - https://wordpress.org/plugins/cart-rest-api-for-woocommerce/? I tried with Postman and it is working. But I don't have an idea to link it with this woocommerce flutter plugin. |
According to this documentation https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/a404e5b24814240f15e50aa4f983b787bb9b36f1/src/StoreApi/docs/cart.md#add-item, nonce token needs to be included with the header. It can be generated by wp_create_nonce( 'wc_store_api' ) but I don't have any idea to do this. I'm a new born WP user, just 1 week old :). |
I am having the same issue. Please help ! |
I have the same issue, anyone there who can solve it. |
"message": "Missing the X-WC-Store-API-Nonce header. This endpoint requires a valid nonce.", |
The reason why you are seeing the error is due to API requiring not just any nonce, but a specific one. Don’t just pass the value return from wp_create_nonce(‘my-string’), the value has to come from wp_create_nonce( ‘wc_store_api’ ) you can read more about it here: https://digitalapps.com/woocommerce-rest-api-cart-endpoint-error/ |
getxwcStoreAPINonce = () => {
} checkout = (billing, shippping, token, navigation) => {
} I used this way ko solve this missing problem. But now I am getting some other errors. |
I have noticed, this issue while using this sdk. and after several searches . going through almost all the forked versions of this sdk. it seems some have tried to fix the nonce issue , by either generating a nonce and sending it , or trying to get it from storeapi but to non existing routes. So after going through the original source codes of the storeApi by https://github.com/woocommerce/woocommerce-gutenberg-products-block. I found that in the woocommerce-gutenberg-products-block/src/StoreApi/Routes/AbstractRoute.php it would send a response header with X-WC-Store-API-Nonce Created.
After sending requests to the api route /wp-json/wc/store/cart/ through an Api client . it returns as this parts of the header if I made a plain Get request to https://yoursite.com/wp-json/wc/store/cart/ As the api accepts Authorization header to make calls to you can initialize the cart 1st by capturing the Get response header from a call to this is as far as I have come to understanding. now to Code 😄 still new to flutter or programming. |
I'm facing the same issue here... |
step1 : fetch this : GET https://www.mysite.com/wp-json/wc/store/cart/items I search many time and try many ways and finally find this way. I hope you can use it. |
Thank you, I searched a lot on the internet how we gain the nonce. But finally I know! |
How to solve this ? |
Hi i have this issue.
Did i must install some plugin or change settings on my woocommerce ?
The libs i the 0.9.6
Tnk's
The text was updated successfully, but these errors were encountered: