Woocommerce休息认证错误401

时间:2017-02-23 14:59:43

标签: nginx woocommerce-rest-api

我在Woocommerce Rest Api上收到401错误

  • Woocommerce上一个版本
  • 禁用WP调试
  • Nginx Server
  • 正确配置(密钥)
{"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())

1 个答案:

答案 0 :(得分:3)

问题是Nginx服务器阻止:

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

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

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

重新启动nginx之后。