Generate customer access token in Magento using specify username and password of the customer in the payload request.
By default, a customer token is valid for 1 hour only. To change the default value of the system,
Go to admin panel,
Click Left sidebar Stores > Settings > Configuration > Services > OAuth > Access Token Expiration.
Enter a new value for Customer Token Lifetime(hours) in the text box.
Save Config.
EndPoint URL:
<HOST_URL>/rest/{store_code}/V1/integration/customer/token
Where store_code is your store code. Native store_code is the default.
Action:
POST
Headers:
Content-Type: application/json
Payload Request Body:
{ "username":"username@fake.com", "password":"your_password" }
Response:
yo1cusx5lo69kdmulbzcquruiuv67lko
On Success of Payload data, Magento returns the customer’s access token with 32 character random string.
You need to use a response string for the authorization header of every call where the customer access token is needed.
Example, To create a new address, you need to use access token In the header of request call,
Authorization Bearer <CUSTOMER_ACCESS_TOKEN>
Authorization Bearer yo1cusx5lo69kdmulbzcquruiuv67lko