WooCommerce - woocommerce_rest_cannot_view - Status 401

前端 未结 10 808
眼角桃花
眼角桃花 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:31

    Try this, I had the same issue with the automattic/woocommerce library and I just got it working by appending the customer_key and customer_secret to the query.

    $woocommerce->get("customers/$userId?consumer_key={$this->key}&consumer_secret={$this->secret}");
    

    Quick Edit


    The above method works but I found a better solution for the automattic/woocommerce library.

    Set query_string_auth to true

    Had to dig into the code to find this setting.

    Found nothing on it in the docs

    return new Client($this->url, $this->key, $this->secret, [
        "query_string_auth" => true
    ]);
    

提交回复
热议问题