Calling await Session.getSession throws exception if there is no session. I was expecting it will return undefined. Is this a bug?
r
rp_st
06/30/2023, 9:52 AM
this is expected. If you want to make it return undefined, you can pass in sessinoRequired: false in the options arg
f
fdundjer
06/30/2023, 9:52 AM
I tried that, here is the code:
Copy code
const session = await Session.getSession(
input.options.req,
input.options.res,
{
sessionRequired: false,
overrideGlobalClaimValidators: () => [], // We remove claim checking here, since this needs to be callable without the second factor completed
},
);
This is 2fa example from supertokens website
fdundjer
06/30/2023, 9:55 AM
Error messsage: Failed to verify access token
Error type: TRY_REFRESH_TOKEN
fdundjer
06/30/2023, 10:07 AM
Here is the info from supertoken logs
fdundjer
06/30/2023, 10:08 AM
Copy code
com.supertokens {t: "2023-06-30T10:07:00.449Z", message: "getInfoFromAccessToken: Returning TRY_REFRESH_TOKEN because access token validation failed - no applicable key found in the JSON Web Key Set", file: "/Users/**/backend/node_modules/supertokens-node/lib/build/recipe/session/accessToken.js:215:22" sdkVer: "14.1.1"} +0ms
SuperTokens is an open source authentication solution offering features like: Different types of login: Email / password, Passwordless (OTP or Magic link based).