woocommerce / wc-api-ruby

A Ruby wrapper for the WooCommerce API.
MIT License
69 stars 74 forks source link

Cannot pass through 'Invalid Signature' error. Problem with signature. #27

Closed nazartaran closed 8 years ago

nazartaran commented 8 years ago

Hello, I've been trying to use this gem to get access to my wordpress site, but I'm always ending up with this error: "errors":[{"code":"woocommerce_api_authentication_error","message":"Invalid Signature - provided signature does not match"}] Tried everything. Re-generated customers secret and key a few times and still got nothing. Built my own query based on this topic: https://gist.github.com/cheenu/1469815 and still getting the same error. I'm not sure if the problem is with the gem itself, or my wordpress part, or something else. Please, can you help me understand what's the issue here?

My code is pretty straightforward:

woocommerce = WooCommerce::API.new(
   "http://www.mywebsite.com/",
   "ck_bla",
   "cs_bla",
    {
       debug_mode: true,
       version: "v3"
    }
 )
woocommerce.get('orders')

Woocommerce plugin version 2.5

My WP site is on London Time and My local computer is on UTC +2 can this cause the issue with signature not being valid?

nazartaran commented 8 years ago

After a few hours of searching I was finally able to figure out what the issue was about - turns out that my wordpress nginx server had this config in the etc/nginx/sites-available/my-site

location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                # try_files $uri $uri/ =404;
                  **try_files $uri $uri/ /index.php?q=$uri&$args;**
                # Uncomment to enable naxsi on this location
                # include /etc/nginx/naxsi.rules
        }

instead of this try_files $uri $uri/ /index.php?$args;

changed it and everything worked fine