Reputation: 2327
I am working on an Ionic 2 project for a woocommerce store. I am using Woocommerce REST API in my app and for testing the API with OAuth-1.0 using Postman Chrome App. I am getting proper responses with GET requests but for POST requests, I am getting error of signature mismatch, as:
{
"code": "woocommerce_rest_authentication_error",
"message": "Invalid Signature - provided signature does not match.",
"data": {
"status": 401
}
}
Upvotes: 3
Views: 2743
Reputation: 21
I struggled with this for a few days (using angular) and finally figured out that it was a CORS issue. The browser actually sends an OPTIONS request, which the woocommerce-api receives as GET. Using this tool helped with troubleshooting.
Finally solved it by setting my .htaccess as follows;
RewriteCond %{REQUEST_METHOD} OPTIONS
RewriteRule ^(.*)$ $1 [R=200,L,E=HTTP_ORIGIN:%{HTTP:ORIGIN}]]
Header set Access-Control-Allow-Origin "*"
Header always set Access-Control-Allow-Credentials "true"
Header always set Access-Control-Max-Age "1000"
Header always set Access-Control-Allow-Headers "X-Requested-With, Content-Type, Origin, Authorization, Accept, Client-Security-Token, Accept-Encoding"
Header always set Access-Control-Allow-Methods "POST, GET, OPTIONS, DELETE, PUT"
You can refer to this answer for a detailed explanation
Upvotes: 2