2017-02-23 101 views
1

我對Woocommerce REST APIWoocommerce休息驗證錯誤401

  • Woocommerce得到401錯誤最後版本
  • WP調試禁用
  • 的Nginx服務器
  • 驗證配置正確(鍵)

{"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()) 

回答

2

問題是Nginx的服務器塊:

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

的位置塊(用於woocommerce)正確的配置是:

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

這個重啓nginx的後。