We are currently encountering an issue with customer access tokens within our Shopify storefront. Our website operates without a session time functionality. When a user logs in, we create a customer access token using their username or password. However, after a span of 4 to 7, when attempting to add an item to the cart, we are receiving an error stating “Customer Is Invalid.”
We suspect this error might be due to the expiration of the customer access token. Could someone kindly clarify the duration for which a customer access token remains valid before expiration? Understanding this time frame will help us address the issue more effectively.
Please find below my query to generate the customer access token.
The error “Customer Is Invalid” confirms that your access token has expired. By default, Shopify Storefront Customer Access Tokens are valid for approximately 6 weeks (45 days) from creation, though this can vary. You can verify the exact expiration time for any specific user by logging the expiresAt value that is already present in your mutation response.
To combat this, you should not force the user to log in again. Instead, implement the customerAccessTokenRenew mutation. Your application should check the stored expiresAt date in the background; if the token is expired or close to expiring, use the renewal mutation to silently generate a fresh token so the user can continue their session without interruption.