I have searched completely in Woocommerce REST API documentation for the endpoint of user login/signup but unable to find it. Can anyone provide me the link to the endpoint and its documentation?
You can achieve this in lot of ways.
1st method is:
It's not specific for WooCommerce but also for all WordPress login and sign up
For sign up:
Method POST
Params : username,email,password
https://example.com/wp-json/wp/v2/users
It will create a new user
For login:
Method POST
Params : username/email,password
https://example.com/wp-json/jwt-auth/v1/token
It will generate an access token which you can pass in for your future requests.
You can use JWT Authentication for WP REST API for login purposes
For reference: Woocommerce users or customers are actually Wordpress users, more like blog subscribers (just like woocommere products are wordpress posts, so to create a user you could use WP_API functions for that purpose.
wp_create_user To create users with minimum parameters (username, password and email).
wp_insert_user To create users with extended user data.
I assume that user roles must match those that woocommerce handle (customers or shop managers)
Now there's also an endpoint for creating/updating/listing customers in WooCommerce REST API (http://woothemes.github.io/woocommerce-rest-api-docs/#customers) but there's no login/auth support at the moment.
For login/authenthication there's two mechanisms in the WP_API: CookieAuth and OAuth If you explain what you are trying to accomplish it would be easier to help.
You can create / signup
user by hitting customers/
endpoint with params : username
, email
and password
.
later you can insert more details like shipping or billing address by hitting customers/<userid>
Now, There's no endpoint available in the REST API for login customers but,
You can achieve this by:
https://yourdomain.com/wp-json/jwt-auth/v1/token?password=123456789&username=nicename
NOTE: it is recommended to use a username instead of email for login a customer because WordPress authenticates the user by the username.
define('JWT_AUTH_SECRET_KEY', 'your-top-secrect-key');
in your wp-config.php
file.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With