我已经创建了一个自定义WooCommerce APIendpoint(在自定义WP插件中),用于在WooCommerce中创建新订单。我通常使用HTTPS和基本身份验证与消费者密钥和消费者机密。
此客户API旨在由另一个无法在请求头中输入使用者密钥和密码的平台访问。所以我只想禁用这个插件的WooCommerce身份验证。我将通过比较密钥使用原始请求中的字段进行身份验证。
有人知道怎么做吗?
我找到了解决办法:
// 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 );
如果要禁用v3的身份验证,请禁用plugins/woocommerce/incudes/api/legacy/v3/class-wc-api-authentication中的第152行和第153行。php
//$this->check_oauth_signature( $keys, $params );
//$this->check_oauth_timestamp_and_nonce( $keys, $params['oauth_timestamp'], $params['oauth_nonce'] );