Woocommerce 休息身份验证错误 401

Woocommerce rest authentication error 401

我在 Woocommerce Rest 上遇到 401 错误 Api


{"code":"woocommerce_rest_authentication_error","message":"Assinatura inv\u00e1lida - a assinatura fornecida n\u00e3o confere.","data":{"status":401}}
{'x-robots-tag': 'noindex', 'x-content-type-options': 'nosniff', 'x-powered-by': 'PHP/5.5.9-1ubuntu4.17', 'transfer-encoding': 'chunked', 'access-control-expose-headers': 'X-WP-Total, X-WP-TotalPages', 'keep-alive': 'timeout=5', 'server': 'nginx', 'connection': 'keep-alive', 'link': '<http://subdomain.example.com/wp-json/>; rel="https://api.w.org/"', 'date': 'Thu, 23 Feb 2017 14:51:35 GMT', 'access-control-allow-headers': 'Authorization, Content-Type', 'content-type': 'application/json; charset=UTF-8'}

import sys
from WooCommerceClient import WooCommerceClient
import pprint

wc_client = WooCommerceClient('ck_8fe372c78d82bf65ff454f68abfe35b8d6140e9d', 'cs_52bd7c4693a26808b66edb7d1f7cad98e5cb213f', 'http://subdomain.example.com/')
pprint.pprint(wc_client.get_products())

问题出在 Nginx 服务器块:

location / {
        try_files $uri $uri/ /index.php?q=$uri&$args;
}

位置块(对于 woocommerce)的正确配置是:

location / {
try_files $uri $uri/ /index.php?$args;
} 

重启nginx后