Magento 2 API – Generate Customer Token Using Customer ID
Greetings, Magento developers! Today, I have a module to share with you for a custom Magento 2 API to generate customer token using customer ID. This module will come in handy if you are developing an app based on Magento 2 and need to re-generate the customer token from the admin side.
Here's the backstory:
One day, a colleague approached me and asked, "Is there a way to generate a customer token using their ID through the Magento 2 API?" He was working on an Android app and wanted to keep the customer's session active based on their activity. Increasing the token expiration time to infinity was not a feasible option from a security standpoint.
So, we decided to create a custom Magento 2 REST API that could be used to regenerate the token before it expired, thereby keeping the session active.
In this post, I will share the complete module for the custom API and provide instructions on how to use it.
Comments
Post a Comment