WooCommerce - woocommerce_rest_cannot_view - Status 401

前端 未结 10 951
眼角桃花
眼角桃花 2021-01-02 00:09

I have generated a consumer key and consumer secret. The website has SSL installed. I have also installed plugins required for JSON and REST services. This is how the url lo

10条回答
  •  庸人自扰
    2021-01-02 00:36

    I met same problem.

    Here is how I solve it:

    require "woocommerce_api"
    
    woocommerce = WooCommerce::API.new(
      "https://example.com",
      "consumer_key",
      "consumer_secret",
      {
        wp_json: true,
        version: "wc/v1",
        query_string_auth: true
      }
    )
    

    The key is query_string_auth: true you need to force basic authentication as query string true under HTTPS

提交回复
热议问题