I've created an app that gets its accessToken through the createShopifyAuth and afterAuth functions, as described by the Node and React tutorial. This is then saved to ctx.session.accessToken, and allows for me to make requests with ctx.session as long as they are made from within the app.
If I however want to make a request from another app, to an endpoint in my Shopify app, which then in turn makes a request to the Shopify API, I need to have it saved elsewhere. I therefor also save the accessToken in my database in the afterAuth function.
Here comes the issue though:
Using the accessToken this way, from my database, seems to work fine for a day or maybe a couple of days, and then I start getting an error saying accessToken or API key is incorrect. I then have to go back to https://[MY_APP_URL]/auth?shop=[MY_SHOP].myshopify.com to get a new accessToken to be able to make the same type of requests.
What is causing this change in accessToken all of a sudden? Going to the link above is the only thing I've noticed I can do to make it change manually without reinstalling, but that also updates the accessToken in my database, so if that was the only place it could happen there would not be an issue.
Hope anyone has an idea what could be causing this!
Offline access tokens do not expire, which tells me you're probably working with online access tokens (which last as long as the user's web session). I'd recommend giving this a read: https://help.shopify.com/en/api/getting-started/authentication/oauth/api-access-modes
Did you get to the bottom of this? I'm having a similar issue.
I am also creating an app with is an intermediary to manage my store. As such, I send the access token to my store's database. However after about a day, this token no longer seems to work when making calls from the external store.