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

无法通过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?

  • 写回答

1条回答 默认 最新

  • drbae3964 2016-01-25 07:03
    关注

    If you look at woocommerce/includes/api/class-wc-api-authentication.php the authenticate function says:

    if ( is_ssl() ) {
        $keys = $this->perform_ssl_authentication();
    } else {
        $keys = $this->perform_oauth_authentication();
    }
    

    which means you can not use oAuth for https. (According to woocommerce you need not.)

    SSL-encrypted requests are not subject to sniffing or man-in-the-middle attacks, so the request can be authenticated by simply looking up the user associated with the given consumer key and confirming the consumer secret provided is valid

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 matlab不知道怎么改,求解答!!
  • ¥15 永磁直线电机的电流环pi调不出来
  • ¥15 用stata实现聚类的代码
  • ¥15 请问paddlehub能支持移动端开发吗?在Android studio上该如何部署?
  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持