Enabling refresh token on FastStore
Automatically refresh user sessions without re-logging in by enabling the refresh token flow in your FastStore project.
2 min read
Refresh token is a security mechanism that allows users to obtain a new, short-lived access token without requiring them to log in again.
The FastStore SDK Session includes built-in support for the refresh token flow. It automatically manages token renewal, session management, and error handling.
As a FastStore user, you only need to enable the refresh token in your project configuration. The SDK will manage the process automatically, without requiring you to implement a custom flow.
In this guide, you'll learn how to enable the refresh token in a FastStore store.
For details about how the refresh tokens work, check the Refresh token flow for headless implementations guide.
Before you begin
Update your FastStore project
Make sure your project is updated to the latest version. To do so, follow these steps:
- Open your project in a code editor.
- Open a terminal and run the following command to update the FastStore packages to the latest version:
_10yarn upgrade -L --scope @faststore
Enable persistent login
In the VTEX Admin, enable persistent login and set the refresh token expiration time (from 1 to 365 days):
- Go to Account settings > Authentication.
- On the Webstore tab, find the Persistent login card and click the toggle to enable it.
- To change the duration, click
Edit, enter a number of days from 1 to 365 in the Session duration field, and clickSave.
For more details, see Configuring persistent login for customers. Without persistent login enabled in your account, you won’t be able to enable the refresh token in your project.
Instructions
-
Open your FastStore project in a code editor.
-
In the
discovery.config.jsfile, under theexperimentalsection, add therefreshTokenflag and set its value totrue: -
Commit and push your changes to the main branch to deploy the changes to production.