WooCommerce REST API : Auto generating API keys using our Application Authentication Endpoint

woocommerce REST API : Auto generating API keys using our Application Authentication Endpoint

API Authentication Endpoint

This woocommerce REST API endpoint can be used by any Application to allow users to generate woocommerce REST API keys for your Application.

This makes integration with WooCommerce API simply because the user only needs to grant access to your Web Application using a URL.

And then being redirected back to your Application, the woocommerce REST API keys will be sent back in a separate HTTP POST request.

Also Read: WooCommerce REST API CRUD Tutorial From Scratch

The following Diagram illustrates how this step by step works:

WooCommerce REST API : Auto generating API keys (Using Authentication Endpoint)

woocommerce-auth-endpoint-flow-f04049df
woocommerce-auth-endpoint-flow-f04049df

Step 1: first of all To generate a URL for our web authentication endpoint is quite simple step.

and then You must use our new path like this /wc-auth/v1/authorize woocommerce REST API endpoint as well as pass the bellow some parameters as query string:

  • app_name – Your app name
  • scope – somm types of the Level of access. Available: like as a read, write and read_write
  • user_id – Set here User ID in your Application (for your internal unique reference)
  • return_url – web URL that will be used for get the user back
  • callback_url – web URL that will get the generated API key. final and last IMP Important to step that this URL should be over SSL (HTTPA)

How to Develop an Extension for WooCommerce via Auto generating API keys

PHP Code (index.php)

 'For testing w3diy Application By w3diy',
	'scope'        => 'read_write',
	'user_id'      => 1,
	'return_url'   => 'https://appv1.yourdomainame.com/wc/app.php',
	'callback_url' => 'https://appv1.yourdomainame.com/wc/log.php'
);

echo $store_url . $endpoint . '?' . http_build_query( $params );

print Bellow URL and redirect To PHP

https://appv1.yourdomainame.com/projectname/wc-auth/v1/authorize?app_name=My+App+Name&scope=write&user_id=123&return_url=https%3A%2F%2Fappv1.yourdomainame.com%2Fwc%2Ftest.php&callback_url=https%3A%2F%2Fappv1.yourdomainame.com%2Fwc%2Ftest.php

woocommerce docs

Ref: https://woocommerce.github.io/woocommerce-rest-api-docs/#rest-api-keys

Leave a Comment