I need customer id and token number when login customer account in Magento2
I used this API for customer login:
Method: Post rest/V1/integration/customer/token
Body
{
"username" : "abc@gmail.com",
"password" : "abc12345!";
}
customerrest
I need customer id and token number when login customer account in Magento2
I used this API for customer login:
Method: Post rest/V1/integration/customer/token
Body
{
"username" : "abc@gmail.com",
"password" : "abc12345!";
}
Best Answer
The following endpoint (the one you mentioned) will return the access token upon submitting correct user credentials:
Then all you need to do is pass that token as a bearer token to this next endpoint and you'll receive all the details for that customer:
Example Request
curl --request GET \ --url https://example.com/rest/V1/customers/me \ --header 'authorization: Bearer x6qa7biotlej2s2li1tl3zzx5ww42lt8'
Example Response
Customer id is
id
in the response