douzi2785
2016-01-23 19:00
浏览 167
已采纳

无法通过SSL在WooCommerce API上使用oAuth身份验证

I am trying to access a V3 version of the WooCommerce REST API using oAuth for authentication over SSL.

The Wordpress instance where WooCommerce is running which I am calling against is hosted using AWS Elastic Beanstalk.

When trying to use oAuth I am getting a 401 response. The URL that the request is made against is https://www.example.com/wc-api/v3/products?oauth_consumer_key=[my_key]&oauth_nonce=[nonce]&oauth_signature=[signature]%3D&oauth_signature_method=HMAC-SHA1&oauth_timestamp=1453572852&oauth_token=&oauth_version=1.0&filter%5Blimit%5D=500

As part of the response I get

[WWW-Authenticate] => Array
    (
        [0] => Basic realm="WooCommerce API. Use a consumer key in the username field and a consumer secret in the password field"
    )

I know the consumer key and secret I am using are fine, as I have been able to use them within a basic authentication request to the same site successfully.

I have tested the same oAuth code against a non-ssl address in my development environment (this is not on AWS) which worked fine.

I know WooCommerce say you must use oAuth for requests on http addresses - but is the opposite the case where you cannot use oAuth for requests on https? Or is there something I need to configure server side which is likely different between my dev environment and the production environment on AWS?

图片转代码服务由CSDN问答提供 功能建议

我正在尝试使用oAuth通过SSL访问WooCommerce REST API的V3版本。

正在运行WooCommerce的Wordpress实例使用AWS Elastic Beanstalk托管。

尝试使用oAuth时,我收到了401响应。 n请求的URL是 https://www.example.com/wc-api/v3/products?oauth_consumer_key= [my_key]& oauth_nonce = [nonce]& oauth_signature = [signature ]%3D& oauth_signature_method = HMAC-SHA1& oauth_timestamp = 1453572852& oauth_token =& oauth_version = 1.0& filter%5Blimit%5D = 500

作为回复的一部分 我得

  [WWW-Authenticate] =>  Array 
(
 [0] => Basic realm =“WooCommerce API。在用户名字段中使用消费者密钥,在密码字段中使用消费者密钥”
)
   \  n 
 

我知道我使用的消费者密钥和秘密很好,因为我已经能够在对同一网站的基本认证请求中成功使用它们。

I 已经在我的开发环境中测试了与非ssl地址相同的oAuth代码(这不是在AWS上),它工作得很好。

我知道WooCommerce说你必须在http上使用oAuth来处理请求 地址 - 但与你不能在https上使用oAuth请求的情况相反? 或者我需要配置服务器端,这可能在我的开发环境和AWS上的生产环境之间有所不同吗?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题