禁用自定义端点的WooCommerce API身份验证

时间:2018-02-16 17:24:39

标签: wordpress restful-authentication woocommerce-rest-api

我创建了一个自定义WooCommerce API端点(在自定义WP插件中),用于在WooCommerce中创建新订单。我通常使用HTTPS和基本身份验证与消费者密钥和消费者秘密。

此客户API旨在由另一个无法在请求标头中输入使用者密钥和密钥的平台访问。所以我想仅为此插件禁用WooCommerce身份验证。我将通过比较密钥来使用原始请求中的字段进行身份验证。

有谁知道怎么做?

2 个答案:

答案 0 :(得分:1)

我找到了解决方案:

// To disable authentication, hook into this filter at a later priority and return a valid WP_User

    add_filter( 'woocommerce_api_check_authentication', array( $this, 'authenticate' ), 0 );

答案 1 :(得分:-1)

如果要禁用v3身份验证,请在plugins / woocommerce / incoudes / api / legacy / v3 / class-wc-api-authentication.php中禁用152、153行

//$this->check_oauth_signature( $keys, $params );
//$this->check_oauth_timestamp_and_nonce( $keys, $params['oauth_timestamp'], $params['oauth_nonce'] );