0
votes

I am integrating Woo-commerce API's in my Laravel 5.6 site using Woo-commerce official rest sdk. I made a link using authentication endpoint URL.Which is mention at here .

When user clicks the link it takes the user to Woo-commerce authentication page, where user login and Approve the request.

After approving the request it should take me to return url which i mention in the link. Instead it shows me the following error.

Error: An error occurred in the request and at the time were unable to send the consumer data.

Here is my code. `$store_url = 'YourStoreUrl';

    $endpoint = '/wc-auth/v1/authorize';
    $params = [
        'app_name' => 'YourApplicationName',
        'scope' => 'read_write',
        'user_id' => 'yourUserId',
        'return_url' => 'YourStoreUrl/callbackurl',
        'callback_url' => 'YourStoreUrl/returncallback'
    ];
    $query_string = http_build_query( $params );

    $url =  $store_url . $endpoint . '?' . $query_string;`
1
You should put your current code hereMahdi Mirhendi
Sorry forgot that my link generation added. I follow the woocommerce doc.Saif

1 Answers

0
votes

For future users who may have this same problem, ensure that your callback_url is correct. The error is mostly due to the callback_url.

In my case, I initially had this piece of python code:

store_url = 'http://localhost/wordpress'
endpoint = '/wc-auth/v1/authorize'
params = {
    "app_name": "My app",
    "scope": "read_write",
    "user_id": 123,
    "return_url": "http://localhost/wordpress/",
    "callback_url": "https://f46c7c857579.ngrok.io",
}
query_string = urlencode(params)

return "%s%s?%s" % (store_url, endpoint, query_string)

But my callback_url was wrong. When I put in the correct callback_url, the error vanished. callback_url": "https://f46c7c857579.ngrok.io/return"

Also, make sure your callback_url has the POST HTTP METHOD