-
Notifications
You must be signed in to change notification settings - Fork 390
InvalidJwtError: Failed to parse session token when using Shopify.Utils.loadCurrentSession #137
Comments
I have the same question . |
Hey @znapfel, the This is quite curious, I wonder if it happens because your request is happening too quickly after loading the app, so that the token isn't active yet. Just so we can rule out an issue on app bridge, could you please try a couple of different things?
Let me know how that goes and we can raise the issue to App Bridge if we're getting an invalid value. |
@paulomarg Yeah. that's what it seems like. It's happening because the token isn't active yet. I am using a workaround by setTimeout (not ideal), but that seems to work fine for now. |
In my case, the |
@paulomarg is there a way to use I have this issue, I don't know if any of you have dealt with it, everything works fine when I install/load the app, even on incognito; I'm using the same approach as @znapfel to request data needed in the frontend from the backend, the only difference is that I'm using route in server.js
function to perform requests in a page, in this case index.js
But whenever I log out from the admin dashboard and log in again, a new session is generated but is never updated on my app; this causes a very weird issue where my custom endpoint will accept the request from the frontend as I'm sending a session token (which has a 1 minute expiration time) in the I decided to debug the app and noticed that in that scenario, when loading the app and hitting the This is why I was trying to load the current session and compare the session values, to then redirect to the auth process if they didn't matched but the Oddly enough, when I directly hit any of my other pages that are not It's not clear to me what's the difference between the session token that we store using the Any help will be highly appreciated, thanks. |
It looks like my clock was no longer synced after a Windows 10 update I applied between when Manually syncing the clock fixed the issue with Thanks @paulomarg and @VladimirCatrici! |
Glad to hear that @znapfel, I'll go ahead and close this issue then since it wasn't a problem with the library code itself. |
On my machine that syncs with time.apple.com nbf can be about 1-2 seconds ahead. Perhaps a clockTolerance at this line would be an idea if many app developers experience this issue |
guys, this is also happening to me. seems like only on local environment. requests made right after starting the server are working but after a few mins they fail with the jwt error |
@giladv You can try settimeout or recursive function on local environment (If time sync isn't working). This is just a suggestion for dev environment. Try this approach.
Pseudocode. (I haven't tested this yet) const helperFunc = async (ctx) => { Again, this is hacky way to handle it but it should work for a testing environment. You might need to improve/change it for production. |
thanks @karmapandya, but the error for me is originated from
but this is not not something we can actually use long term, not even for development. |
Facing the same problem from windows 10. |
Can confirm this on Ubuntu. Settings -> turn on/off automatic date/time and then app worked fine. |
Confirmed that sync system clock on Win10 works. If you are using the Win10 system for development:
|
This is crazy I wasted so much time and it was because my computer was not in sync... things like this humbles any developer |
I'm still getting this error every 2 to 3 days in my dockerized app |
solved the problem with sync button in windows 10 (settings time&date ) |
The same proble with me, The solution is to switch from manualy local time to auto timing on my machine. OS: ubuntu |
I have this issue also on heroku on production |
have this issue on fly.io |
I'm constantly getting these on Heroku. It crashes the app:
|
Issue summary
Hi there,
Thanks for making this node API!
I've been making a test development app to learn more about how cookieless sessions should work in Shopify apps.
However,
Shopify.Utils.loadCurrentSession
is suddenly failing to parse session tokens provided by making a request to API routes usingauthenticatedFetch
from@shopify/app-bridge-utils
. This was working late last week, but when I loaded my development app today, this suddenly started failing with no changes on my part.Expected behavior
authenticatedFetch
should request the data from my test route and attach theAuthorization
header, which is then parsed within the Shopify object on the back end and return a session, which I can check the presence of, and complete the API request with dummy data.Actual behavior
The session now fails to load in the
/test
route, due to a failure to parse the provided token that the authenticatedFetch is attaching to the request. The base 64 string matches in the backend error logs and on the front end network request, though:Frontend request
server error
What actually happens?
Steps to reproduce the problem
getTestData
will make the request to the api route specified in server.jsShopify.Utils.loadCurrentSession
. This was working on Friday with the below reduced test case, but now it's not.Reduced test case
server.js
index.js - Main Page of React App
Checklist
The text was updated successfully, but these errors were encountered: