App reviews, troubleshooting, and recommendations
Hi,
How to increase the lifetime of the customerAccessToken expiresAt? I can't find any documentation to increate the lifetime of the customer access token.
Thank You
See if this works for you.
In Shopify, the CustomerAccessToken
is a token that is generated when a customer logs in or creates an account on your store. This token is used to authenticate the customer's requests to your store's API.
The lifetime of a CustomerAccessToken
is determined by the expires_at
field in the token's metadata. By default, the lifetime of a CustomerAccessToken
is 1 hour (3600 seconds).
To increase the lifetime of a CustomerAccessToken
in Shopify, you can follow these steps:
Retrieve the CustomerAccessToken
that you want to modify by making a request to the Shopify API.
Determine the new expires_at
time that you want to set for the token. This can be any valid timestamp in the future.
Update the expires_at
field in the CustomerAccessToken
metadata with the new timestamp.
Save the updated CustomerAccessToken
to the Shopify API using a PUT
request.
Here's an example of how to update the CustomerAccessToken
expiration time in Shopify using the Shopify API and the Shopify API client for Node.js:
const Shopify = require('shopify-api-node');
// Initialize the Shopify API client
const shopify = new Shopify({
shopName: 'your-shop-name',
accessToken: 'your-access-token'
});
// Retrieve the CustomerAccessToken
const customerAccessToken = await shopify.customerAccessToken.get(customerAccessTokenId);
// Set the new expiration time
const newExpiresAt = new Date(Date.now() + 7200 * 1000); // 2 hours from now
// Update the CustomerAccessToken
customerAccessToken.expires_at = newExpiresAt.toISOString();
await shopify.customerAccessToken.update(customerAccessTokenId, customerAccessToken);
In this example, we first retrieve the CustomerAccessToken
using its ID. We then set the new expiration time to 2 hours from the current time. Finally, we update the CustomerAccessToken
in Shopify using the updated metadata.
Thank you , Let me try it out
Shopify and our financial partners regularly review and update verification requiremen...
By Jacqui Mar 14, 2025Unlock the potential of marketing on your business growth with Shopify Academy's late...
By Shopify Mar 12, 2025Learn how to increase conversion rates in every stage of the customer journey by enroll...
By Shopify Mar 5, 2025