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

问题描述 投票:0回答:2

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

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

有谁知道如何做到这一点?

wordpress restful-authentication woocommerce-rest-api
2个回答
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
投票

如果要禁用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'] );
© www.soinside.com 2019 - 2024. All rights reserved.