'Disable WooCommerce API authentication for Custom endpoint

I have created a custom WooCommerce API endpoint (in a custom WP plugin) for that creates a new order in WooCommerce. I usually use HTTPS and basic auth with consumer key and consumer secret.

This customer API was designed to be accessed by another platform that does not have the ability to enter consumer key and secret in request header. So I would like to disable WooCommerce authentication for this plugin only. I will be authenticating using a field in the original request by comparing a key.

Does anyone know how to do this?



Solution 1:[1]

Comment below lines in file woocommerce/includes/class-wc-rest-authentication.php

    if ( !hash_equals( $signature, $consumer_signature ) ) { @codingStandardsIgnoreLine
    return new WP_Error( 'woocommerce_rest_authentication_error', __( 'Invalid signature - provided signature does not matchh.', 'woocommerce' ), array( 'status' => 401 ) );
}

Solution 2:[2]

If you want to disable authentication for v3, then disable line 152, 153 in plugins/woocommerce/incoudes/api/legacy/v3/class-wc-api-authentication.php

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Reynosh
Solution 2 gui xiao