September 27, 2021

Sanjay Patel 0

How to get a customer token using REST API in Magento 2?

Actually we need to have token to authorize API in Magento 2. We can use customer token to get customer data and run customer authorize api by passing that token.

We devided below 5 points for Rest API :

1. End Point (url)

2. Method (GET, POST, PUT, DELETE)

3. Header

4. Payload (Body)

5. Response

1. End Point (Url) :

– {site_url}/rest/{store_code}/V1/integration/customer/token

{site_url} is your mangeto website url.

{store_code}is optional.

2. Method : POST

3. Header : (key: value)

Content-Type : application/json

4. Payload(Body) :

{

“username”: “{cusotmer_email_address}”,

“password”: “{customer_password}”

}

5. Response (string) :

“{access_token}”

Example : get customer token using Rest API Magento 2 :

End Point : http://127.0.0.1/magento2/rest/V1/integration/customer/token

Method : POST

Header : Content-Type : application/json

Payload :

{

“username”:”customer@cogent.com”,

“password”:”test@123″

}

Response : “hh6gdftke3cp1fslusqbl03sissdrtou”


Thank you for reading…We hope it helps you out. For any assistance contact us.

Follow us on Linkedin

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *