nextjs-shopify-app icon indicating copy to clipboard operation
nextjs-shopify-app copied to clipboard

API Get Products: Unauthorized after 1 day

Open forslunds opened this issue 3 years ago • 6 comments

After a successfull installation with Vercel, Shopify and Upstash everything works wonderful (Awesome job!).

But if i revisit the app in shopify after 1 day, i can still login to the embedded app but the product listing is not showing. Error from Vercel log says following:

ERROR HttpResponseError: Received an error response (401 Unauthorized) from Shopify: [API] Invalid API key or access token (unrecognized login or wrong password). If you report this error, please include this id: XXX-XXX-XXX at HttpResponseError.ShopifyError [as constructor] (/var/task/node_modules/@shopify/shopify-api/dist/error.js:13:28) at new HttpResponseError (/var/task/node_modules/@shopify/shopify-api/dist/error.js:95:28) at RestClient. (/var/task/node_modules/@shopify/shopify-api/dist/clients/http_client/http_client.js:214:55) at step (/var/task/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:143:27) at Object.next (/var/task/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:124:57) at fulfilled (/var/task/node_modules/@shopify/shopify-api/node_modules/tslib/tslib.js:114:62) at processTicksAndRejections (internal/process/task_queues.js:95:5) { code: 401, statusText: 'Unauthorized' }

forslunds avatar Jun 24 '21 08:06 forslunds

Hey @forslunds -- are you using the latest version that uses Upstash/Redis?

t-kelly avatar Jun 29 '21 03:06 t-kelly

Hey, Yes, upstash was hooked up with the installation on vercel. I have to admit im not used too redis, so a bit hard to debug. maybe some configuration is missing if its working for you after a day?

Will try my own customsessionstorage (sql) so i can debug better where the problem is.

forslunds avatar Jun 29 '21 19:06 forslunds

Just to add that I am having the same issue as @forslunds - have not had time to look into it yet but will come back if I find anything. Used the Vercel installation too.

matthew-petrie avatar Jul 06 '21 17:07 matthew-petrie

I'm also experiencing the same problem. I did some digging and it seems that online access mode is used (reference) which limits the session to one day. Should offline mode be used or maybe we need to initiate OAuth process again after the session expires?

konradkalemba avatar Jul 11 '21 18:07 konradkalemba

Yeah, it doesnt fetch new token (oauth) on reentering the app. Online access is the recommended way and it only says in the doc that we should fetch new access everytime there is a new visit, the question is where to put the logic. i leave that to someone else :)

forslunds avatar Jul 12 '21 18:07 forslunds

Hey guys. Does anyone have success on this? I have an issue here too...

mashkovtsevlx avatar Jul 22 '21 15:07 mashkovtsevlx