WP Generate Rest API keys

Setting Up the Development Environment

Website Config

Before we start, make sure you have installed WordPress and WooCommerce and your website is up and running. If you have not installed WordPress yet, start from here: https://wordpress.org

For WooCommerce Required Plugins

Step 1: Configuration of your WordPress website

If you’re using non-pretty permalinks in WooCommerce, the REST API will not work. Configure pretty permalinks in Settings > Permalinks so that the custom endpoints are supported.

Config WordPress permalinks settings.

Step 2: Configuring WooCommerce

Pre-generated keys can be used to authenticate use of the REST API endpoints. New keys can be generated either through the WordPress admin interface or they can be auto-generated through an endpoint.

Generating API keys in the WordPress admin interface

Note: We not require WRITE permission READ is enough.

To create or manage keys for a specific WordPress user, go to WooCommerce > Settings > Advanced => REST API> Keys/Apps.

Generating API keys.

Click the “Add Key” button. In the next screen, add a description and select the WordPress user you would like to generate the key for. Use of the REST API with the generated keys will confirm to that user’s WordPress roles and capabilities.

Choose the level of access for this REST API key, which can be Read access, Write access or Read/Write access. Then click the “Generate API Key” button and WooCommerce will generate REST API keys for the selected user.

Now that keys have been generated, you should see two new keys, a QRCode, and a Revoke API Key button.

App Config

Configure API

Unzip file product.zip located inside the app folder.

API Endpoint and Customer Secret & Key

Open file api.js in product/lib/constants/app.dart and change it with your domain name, customer key and customer secret you generated from Woocommerce -> Settings -> Advanced -> REST API

  1. Open file in below path:

product/lib/constants/app.dart

2. And replace your Rest API keys and domain with below info in app.dart file:

const String baseUrl = 'https://yourdomain.com/';

const String consumerKey = 'ck_xxxxxxxxxxxxxxxxxx';

const String consumerSecret = 'cs_xxxxxxxxxxxxxxx';

Last updated