WooCommerce

How to Authenticate and Verify WooCommerce in an Android App

Chandan Kumar
By Chandan Kumar
August 5, 2017
3 min read
Share The Blog:
Steps to Verify Woocommerce in Android App

If you are building a native Android app for your e-commerce store, connecting it securely to your backend is a crucial first step. In this guide, we will walk you through the exact steps to authenticate and verify WooCommerce in your Android application using the WooCommerce REST API.

Step 1: Configure WooCommerce Settings (Server-Side)

Before touching your Android code, you need to generate the necessary API keys from your WordPress dashboard.

  • Log in to WordPress: Access your admin dashboard.
  • Navigate to Settings: On the left-hand menu, go to WooCommerce > Settings.
  • Enable the REST API: Click on the Advanced tab at the top, then click on the REST API link right below it.
  • Create a New Key: Click the Add key button.
  • Configure Key Details:

Description: Add a friendly name for your app (e.g., “Android App API”).

User: Select the admin user generating the key.

Permissions: Change this to Read/Write so your app can both fetch products (GET) and submit orders (POST).

Generate: Click Generate API Key.

Important: WooCommerce will now display a Consumer Key and a Consumer Secret. Copy these immediately and keep them secure, as you will need them for your Android project.

Step 2: Configure Android App Settings (Client-Side)

Now that your server is ready, let’s set up the Android app to communicate with WooCommerce.

  1. Add the OAuth Library: Add an OAuth library (like ScribeJava) to your Android project. The modern way to do this is by adding the dependency to your build.gradle file, though you can also add the .jar file manually to your app/libs folder.
  2. Store Your Keys: Open your strings.xml file and add the API keys you generated earlier:
<string name="woo_consumer_key">YOUR_CONSUMER_KEY</string>
<string name="woo_consumer_secret">YOUR_CONSUMER_SECRET</string>

3. Create an OAuth Service: Use your Consumer Key and Consumer Secret to initialize an OAuth service that will request an OAuth token for authorization.

4. Construct OAuth Requests: Build your requests based on the action you want to perform:

  • For GET methods: Use this to fetch data like products or categories.
  • For POST methods: Use this to push data, such as creating a new customer or submitting a new order. Ensure you include a JSONObject containing all required parameter values in the body of your request.

5. Send Signed Requests: Construct a signed request for the OAuth service using an async HTTP client method, and send it to your server.

Step 3: Fetch Products from Your WooCommerce Store

Once authentication is set up, you can start pulling catalog data into your app.

To list products belonging to specific categories, you can call the Products API and append the category IDs to the URL. If a parent category has subcategories, simply pass the IDs of all the subcategories in the URL to fetch all relevant products.

Example API Call:

https://your_wordpress_site/wp-json/wc/v3/products?category=26,27,28

Understanding the Product Response: In the JSON response, every product includes a categories array detailing exactly where the product belongs. You can use the category name or ID to filter products dynamically within your app’s UI.

"categories": [
  {
    "id": 26,
    "name": "Subcategory",
    "slug": "subcategory"
  }
]

Pro Tip: When displaying a subcategory screen in your app, use this JSON array to filter the master list so that users only see products relevant to the specific subcategory they are browsing.

Chandan Kumar

Chandan Kumar

Chandan Kumar doesn't just write code; he builds digital legacies. As the Founder and Team Lead at AvyaTech, Chandan combines high-level strategy with granular technical expertise to turn "what if" into "it's live." When he’s not steering his team through complex development sprints, he’s busy architecting the future of scalable, user-first technology.

Related Articles

Continue reading with these hand-picked articles on similar topics.

Customize WooCommerce Emails in Minutes: The Complete Guide 2025
WooCommerce
Customize WooCommerce Emails in Minutes: The Complete Guide 2025
WooCommerce stores offer multiple benefits, including sending automatic emails to customers concerning their orders. Automated emails help in building trust and improving communication. You easily get basic WooCommerce emails by default in CMSs. But you can customize WooCommerce emails to get added advantages. Customizing WooCommerce emails is possible for all WordPress and WooCommerce users. Check […]
Chandan Kumar January 22, 2025
Handy WooCommerce Shortcode Guide for Simplified and Customized eCommerce Store
WooCommerce
Handy WooCommerce Shortcode Guide for Simplified and Customized eCommerce Store
Unlock the power of WooCommerce shortcodes to enhance your store's functionality. Learn to customize pages, display products, and simplify user experience!
Chandan Kumar January 17, 2025
How to Integrate Google Merchant Center with WooCommerce
WooCommerce
How to Integrate Google Merchant Center with WooCommerce
Google Merchant Center, a.k.a. GMC or Google Shopping, is a free-to-use digital platform where online retailers can upload and display their physical products and services on Google. It enables targeted shoppers on Google to discover, explore, and buy at their convenience. The GMC works as a bridge between the Google search engine and your online […]
Chandan Kumar December 9, 2024