App reviews, troubleshooting, and recommendations
Hi, I wanted to get shop access token, so I could do data sync while they're out of session, but when I try to do that I get 401, although I use offline access token taken from sessions table.
Strange thing is that it happens not for all shops, but to some. Another anomaly is that broken shop webhook, but only one, started throwing 401s as well until it got removed.
This is basic script that I use to get access token it:
const apiKey = "..."; const sharedSecret = "..."; const refreshToken = "..."; const accessToken = "..."; // from session table with no expiration, marked offline const shop = "....myshopify.com"; const postData = { client_id: apiKey, client_secret: sharedSecret, refresh_token: refreshToken, access_token: accessToken, }; (async () => { const response = await fetch( `https://${shop}/admin/oauth/access_token.json`, { method: "post", body: JSON.stringify(postData), headers: { "Content-Type": "application/json" }, }, ); console.log(response); // The response includes the updated access token for future requests. const data = await response.json(); accessToken = data["access_token"]; console.log(accessToken); })();
Just to make it clear as well, that shop is still active in my app, it just haven't logged in for quite a while, but my assumption is that it doesn't matter, because offline token, shouldn't expire, so why did it?
Any help would be highly appreciated.
Learn how to build powerful custom workflows in Shopify Flow with expert guidance from ...
By Jacqui May 7, 2025Did You Know? May is named after Maia, the Roman goddess of growth and flourishing! ...
By JasonH May 2, 2025Discover opportunities to improve SEO with new guidance available from Shopify’s growth...
By Jacqui May 1, 2025