Woocommerce REST API only user access their data - wordpress

I need to make a mobile application for a Wordpress based e-commerce site.
I'm researched the WordPress and Woocommerce REST api.
What I want to do is briefly;
To authenticate with username and password via REST API.
if the verification is successful, look previous orders etc.
So only the user needs to access the data about himself!
how is this done ?
Thanks

Woocommerce users or customers are actually Wordpress users
Method POST: 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
Sign up end point:
https://example.com/wp-json/wp/v2/users
Login end point:
https://example.com/wp-json/jwt-auth/v1/token

Related

Authenticating against WooCommerce API with customer usernamer/Password

We are re-building an Easy Order Wordpress plugin with VueJs, that uses WooCommerce REST API.
Current flow: The customer go to the website and do a login with email/password, with the login done, the user can go to 'Easy Order' link to access the plugin and then the user get all products categories, subcategories and products. the user can add/remove products into his cart.
What we are trying to reach: We are changing the plugin to use the WooCommerce REST API, but there is no way to access the data with a customer email/password login in WooCommerce REST API, the Wordpress login does not work at all with WooCommerce REST API.
Has anybody here with the same problem that can give insights about that?
Try Simple JWT Login plugin.
It provides additional endpoints for logging in customers as well as generating unique JSON web tokens. I am using it in my react native app to login customers as well as registering new users.

How to authenticate existing customer via WooCommerce rest API

I am creating a mobile app for a WooCommerce website and have gotten to a stage where I want the user to login or signup to the WooCommerce website before they continue with a purchase.
I can create a new customer no problem but I am having trouble when trying to authenticate an existing customer. After looking at the rest api docs for WooCommerce, I haven't come across any endpoint that will allow an existing user to log in to their account. Is there any endpoint that will allow me to do this that isn't documented?
There might be other ways but what comes to my mind immediately is to use JWT Authentication for WP REST API plugin.
Using this plugin you can request for authentication on the server using the username and password. It will return a token if successful. Then use the token for checking if this user/customer is valid. If valid, use wc api to create an order for this customer.

woocommerce validate user name and password via rest api

I am developing an android app for an eCommerce site that is built in wp-woocommerce.
I really don't know much about wp.
I have read http://woothemes.github.io/woocommerce-rest-api-docs/ and have developed almost all the android app. but I was unable to find a way to validate the username and password of the customer via rest API.
I just want to pass the username and password and expect the result as pass or fail.
Thanks in advance for your kind help.
Unfortunately, WooCommerce REST API doesn't deal with login/logout (customers) as they are treated as WordPress users with CUSTOMER roles.
The API KEY and SECRETE is for your app to fetch data as products - orders etc... You have to use WordPress API login methods to access user information, signup new users/customers,.
WordPress REST API / Auth
If you prefer to use JWT there is many plugins in the plugins repo.I have used this one: Simple JWT Login – Login and Register to WordPress using JWT and works good.

WooCommerce Rest API - how to authenticate customers? [duplicate]

I am creating a mobile app for a WooCommerce website and have gotten to a stage where I want the user to login or signup to the WooCommerce website before they continue with a purchase.
I can create a new customer no problem but I am having trouble when trying to authenticate an existing customer. After looking at the rest api docs for WooCommerce, I haven't come across any endpoint that will allow an existing user to log in to their account. Is there any endpoint that will allow me to do this that isn't documented?
There might be other ways but what comes to my mind immediately is to use JWT Authentication for WP REST API plugin.
Using this plugin you can request for authentication on the server using the username and password. It will return a token if successful. Then use the token for checking if this user/customer is valid. If valid, use wc api to create an order for this customer.

Automatic Login Facebook PHP SDK as in Wordpress Easy Instagram Plugiin

I am creating a wordpress plugin for admin. In which admin can show his selected photos from facebook album on front end.
App id and secret key are storing in db.
Login also working and it fetches the login user albums etc etc.
and Logout also working. But when on the site if some one has logged-in in my plugin then from any system it must show the login details.
What currently its doing is that to login to facebook, which i don't want.
The method i want in my plugin is same as its in wordpress easy instagram plugin, where in the site if the user logged in then it will always show the login credentials what happening in this instagram plugin is that is stores the access token in wp options table. if we delete the value for that option then it will specify in the back end to login.
I want same process in my plugin too.
Auto login process. (one time login)
Anyone knows how to make this work?
Thanks

Resources