Member Token
This article guides you through the process of authenticating members and how to manage their session tokens effectively.
Initial Admin Login
When a member attempts to log in for the first time:
Send a
POSTrequest to the/api/{storeCode}/member/login_checkendpoint with the member's credentials as a JSON payload.
{
"username": "member@example.com",
"password": "password123"
}Upon successful authentication, OpenLoyalty will return a response containing a JWT token and a refresh token:
{
"token": "eyJhbGciOiJSUzI1NiIsInR5cCI...",
"refresh_token": "def50200a2e8c9a2..."
}This JWT token is critical as it must be included in the Authorization header as a Bearer token for the subsequent requests to the API.
Maintaining Authentication State
The JWT token has a validity period of 24 hours. To continue interacting with the API beyond this period without requiring the member to log in again, you will need to refresh the token.
Send a
POSTrequest to the/api/{storeCode}/token/refreshendpoint with the refresh token before the JWT token expires:
If the refresh token is valid, OpenLoyalty will issue a new JWT token along with a new refresh token.
Replace the old JWT token with the new one in the Authorization header for all future requests utilizing member's token.

Best Practices
Token Security: It is critical to handle JWT tokens securely to protect them from interception or unauthorized access.
Token Refresh Strategy: Implementing an automated refresh token strategy will enhance the user experience by preventing session disruptions.
Error Handling: Your client application should be equipped to handle errors during the authentication process, including scenarios where the refresh token has expired, necessitating a full re-authentication.
By following these steps and best practices, you can integrate OpenLoyalty's authentication flow into your application, ensuring secure and seamless access to its API.
Last updated
Was this helpful?

