如何验证WooCommerce REST API

时间:2016-08-17 16:12:35

标签: wordpress rest woocommerce woocommerce-rest-api

我已经生成了消费者密钥和消费者密钥,但我不知道如何在Postman上进行身份验证。这是下面的截图:

screenshot from 2016-08-17 14-28-18

网址如下所示:https://mystore.com/wp-json/wc/v1/coupons?oauth_consumer_key=ck_XXXXXXXXXXXXXXX&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1471440398&oauth_nonce=Qaq8cK&oauth_version=1.0&oauth_signature=XXXXXXXXXXXXXXXXXXXXXXXXXw=

但这是返回错误401:

{ "code": "woocommerce_rest_cannot_view", "message": "Sorry, you cannot list resources.", "data": { "status": 401 } } 我已阅读the documentation但未显示任何示例。

1 个答案:

答案 0 :(得分:1)

如果您的网站使用HTTPS运行,则可以通过Authentication标头发送您的凭据(如果您正在运行WooCommerce,则应该这样做。)

以下是文档的相关部分:
https://woothemes.github.io/woocommerce-rest-api-docs/?shell#authentication-over-https