Calling await Session.getSession throws exception ...
# support-questions-legacy
f
Calling await Session.getSession throws exception if there is no session. I was expecting it will return undefined. Is this a bug?
r
this is expected. If you want to make it return undefined, you can pass in sessinoRequired: false in the options arg
f
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
Error messsage: Failed to verify access token Error type: TRY_REFRESH_TOKEN
Here is the info from supertoken logs
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
3 Views