2
votes

I have a website w/ subscriptions that I've built with WP and WooCommerce. Customers can purchase subscriptions and then download the product once the purchase is complete. So far so good, however I would like to be able to offer a login in the product (a win/mac c++ standalone application) and allow the customer to login using the credentials they have entered while purchasing the product.

There's a few issues blocking this:

  1. WooCommerce does not expose an API to authenticate customers
  2. WooCommerce GET/customer does not return the password of the customer (this makes sense, but would have been useful for duplicating it in another db that I DO have access to via the product)
  3. There are no integrations with any SSO providers such as aws cognito, firebase, etc.

SO with this in mind: How can I authenticate a customer in a standalone product using their woocommerce customer credentials? I've spent hours trying to find a solution and am stumped!

EDIT: Apologies I think I'm using confusing language: I'm looking to authenticate a customer on a separate platform using the credentials they created when they created an account on the subscription platform in WooCommerce.

The flow is:

  1. Customer goes on the website (woo), purchases a subscription and creates an account
  2. Customer downloads the product, installs, and opens it
  3. The product has a login screen that asks for email/password - this should validate the credentials they have entered when purchasing the subscription on the website
1
Can you programmatically login a user on your standalone product? Similar to something like wp_set_current_user()Howard E
The product can authenticate a user via username/pass by checking the creds against it's own database, but I don't think this is what you're asking..? Could you clarify please? My php/wordpress knowledge is pretty limitedNicholas Laroche
You need to check API authentication for this - woocommerce.github.io/woocommerce-rest-api-docs/#authenticationmujuonly
Sorry I meant customer not user, I've edited the question aboveNicholas Laroche

1 Answers

0
votes
<?php
require __DIR__ . '/vendor/autoload.php';

use Automattic\WooCommerce\Client;

$woocommerce = new Client(
    'https://example.com',
    'consumer_key',
    'consumer_secret',
    [
        'wp_api' => true,
        'version' => 'wc/v3'
    ]
);
?>

Authenticate using REST API