Site icon Hip-Hop Website Design and Development

How to authenticate custom API endpoint in WooCommerce [closed]

I have created custom API, which is working fine, but I am not able to authenticate it, it returns result without checking for keys

I have created consumer key and secret key from admin.

How to validate request to API.

I tried one solution, which is working as expected but my question is,

what is the standard way of authentication custom API

my current solution

require_once '/woocommerce/includes/legacy/api/v1/class-wc-api-authentication.php';
$test = new WC_API_Authentication();
$user = wp_get_current_user();
$test->authenticate($user);