t-kelly / nextjs-shopify-app

nextjs-shopify-app-lake.vercel.app
MIT License
127 stars 51 forks source link

API Get Products: Unauthorized after 1 day #3

Open forslunds opened 3 years ago

forslunds commented 3 years ago

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' }

t-kelly commented 3 years ago

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

forslunds commented 3 years ago

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.

matthew-petrie commented 3 years ago

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.

konradkalemba commented 3 years ago

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?

forslunds commented 3 years ago

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 :)

mashkovtsevlx commented 3 years ago

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