i’m trying to use the woocommerce rest_api to create some javascript interations, however i can’t acess this information without set a – OAuth 1.0a “one-legged” authentication – that i check is needed in woocommerce to make this request from a ‘http://’ client. Can someone give me an example of OAuth 1.0 and how can implement it in my AJAX REQUEST for WP_REST Woocommerce ? i’m intersted to know in ‘http://’ and ‘https://’ method if possible, Thank you!

i checked this documentation but i don’t understand exactly how to use it.

Documentation i check – https://woocommerce.github.io/woocommerce-rest-api-docs/#authentication-over-https

my code in functions.php

    wp_enqueue_script('product_request_js', get_template_directory_uri() . '/js/product-request.js', true );

    wp_localize_script('product_request_js', 'product_request', array(
        'product_url' => esc_url_raw( rest_url('/wc/v2/products') )
        )
    );

My current code in js with has denied by authentication:

   $.ajax({
        method: 'GET',
        url: product_request.product_url,
        success: function(products){
            console.log(products);
        }
    })

Read more here: Woocommerce REST_API Authentication methods Help, Http and Https


Solution:

If you know the solution of this issue, please leave us a reply in Comment section, to update the question.


Wordpress related questions and answers: