-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
When Shopify Online Session is lost the Authenticate process in Strapi fails #5
Comments
Which version of the plugin are you using? When you install the Shopify store the session created by installation is an offline session, then the user is redirected to the authentication and a online session is created. This is because an application may need both an offline access token for server usage and an online access token for user authenticated requests. |
Thanks for your answer. There are just some instances like every day or so that the ONLINE session gets deleted from the database. However whenever this happens, (you can replicate this by simply deleting the online session in the database), the |
There are 3 reasons why the plugin deletes the current session and redirects with a 401:
When the redirect happens, if comes from a text/html request it should automatically redirect to the correct endpoint (install/auth), if comes from a normal GET request it should be handled by the frontend:
This is a sample code I use to check if the shop is authenticated and if I shoud do a redirect:
|
The session probably expires and you should authenticate again |
Okay thank your for the reasons of why a session gets deleted. |
Or is the code snippet you posted client side? |
Yes this code should be on the client side, I use it when the app starts to check if the shop is still authenticated or if it should authenticate again or if the scopes are changed and the shop should be installed again. This code was taken from @shopify/koa-shopify-auth but I can't tell you where exactly. That said, I've never tested if instead of returning the headers the app can redirect directly on a GET/POST request made with |
You're probably right, it doesn't but it should |
Understood. Thank you. I was so invested in the backend that i didn't see the obvious. I like your client side solution better. |
For some reason the online session gets deleted from time to time.
Basically a database entry in table session gets deleted. I am not sure why that happens, if its triggered by shopify or the plugin.
However, whenever it does happen the plugin fails to authenticate inside of
/strategies/shopify-auth.js
. It simply fails to load a session (since the db entry is missing). As a result most routes return a 401 since the strapi authentication failed. I am unsure if the plugin should be able to deal with such situations or why they occur.If you have some insight please elaborate.
My only solution to this is to reinstall the app to recreate the session entry. By doing so everything goes back to fuctioning normally.
The text was updated successfully, but these errors were encountered: