supertokens/supertokens-flutter

Session does not exist

Closed this issue · 9 comments

I'm able to send and verify an SMS OTP in my Flutter app, but I'm not able to get any session info on subsequent calls. Also, I'm using the HTTP Client and it does not inject a the Authentication header on requests to my backend.

What am I missing?

It's likely a mis config from your end. Make sure that the apiDomain configured is the apiDomain that you use when making the sign in API call.

Also, make sure that you have added our interceptor as shown in the docs.

It certainly was a mis-config on my end. I am now able to call getUserId() successfully. However, calls to await SuperTokens.getAccessToken() directly after that still return null.

Thoughts?

Can i see the supertokens.init config on the frontend?

SuperTokens.init(
        apiDomain: "https://<REMOVED>.ngrok-free.app",
        apiBasePath: "/auth",
        tokenTransferMethod: SuperTokensTokenTransferMethod.HEADER);
  }

On the backend, I simply have: Session.init()

Stepping through the code on the front-end I see that the access token is still be delivered via sAccessToken cookie. I also confirmed that the st-auth-mode header is set to header on the outgoing request, but I still only get the cookie access code.

Screenshot 2023-11-29 at 12 42 52 PM

Strange. A few questions:

  • Which backend SDK and which version of the backend SDK are you using?
  • Can I see the request headers in the sign in API?

I'm using "supertokens-node": "^12.1.4" with fastify, based off of this example: https://github.com/lirantal/fastify-supertokens-example

The request headers for the /auth/signinup/code request are: {Content-type: application/json; charset=utf-8, st-auth-mode: header, cookie: }

Ah! So the version of the node SDK that supports non cookie based auth is 13.0.0. Please upgrade it (make sure to see the changlog since it's a breaking change from the version you use) and try again.

That was it! Thank you!