https://supertokens.com/ logo
SuperTokens with Serverless
d

devertry|deepsheep

04/17/2023, 7:46 AM
coes super token work on serverless ? like heroku ?
nothing in your search bar
n

nkshah2

04/17/2023, 7:56 AM
Hi, Yes we do work with serverless frameworks, while we dont have dedicated guides for Heroku you can ask questions here if you run into any issues
d

devertry|deepsheep

04/17/2023, 7:57 AM
ok thanks
md
com.supertokens {t: "2023-04-17T08:10:31.758Z", message: "doesSessionExist: called", supertokens-website-ver: "16.0.4"}
logger.js:31 com.supertokens {t: "2023-04-17T08:10:31.758Z", message: "FrontToken.getTokenInfo: called", supertokens-website-ver: "16.0.4"}
logger.js:31 com.supertokens {t: "2023-04-17T08:10:31.758Z", message: "getFrontToken: called", supertokens-website-ver: "16.0.4"}
logger.js:31 com.supertokens {t: "2023-04-17T08:10:31.758Z", message: "getLocalSessionState: called", supertokens-website-ver: "16.0.4"}
logger.js:31 com.supertokens {t: "2023-04-17T08:10:31.759Z", message: "getFrontTokenFromCookie: called", supertokens-website-ver: "16.0.4"}
logger.js:31 com.supertokens {t: "2023-04-17T08:10:31.759Z", message: "getLocalSessionState: returning NOT_EXISTS since frontToken was cleared but lastAccessTokenUpdate exists", supertokens-website-ver: "16.0.4"}
logger.js:31 com.supertokens {t: "2023-04-17T08:10:31.759Z", message: "getFrontToken: Returning because sIRTFrontend != EXISTS", supertokens-website-ver: "16.0.4"}
logger.js:31 com.supertokens {t: "2023-04-17T08:10:31.759Z", message: "getLocalSessionState: called", supertokens-website-ver: "16.0.4"}
logger.js:31 com.supertokens {t: "2023-04-17T08:10:31.759Z", message: "getFrontTokenFromCookie: called", supertokens-website-ver: "16.0.4"}
logger.js:31 com.supertokens {t: "2023-04-17T08:10:31.759Z", message: "getLocalSessionState: returning NOT_EXISTS since frontToken was cleared but lastAccessTokenUpdate exists", supertokens-website-ver: "16.0.4"}
logger.js:31 com.supertokens {t: "2023-04-17T08:10:31.759Z", message: "doesSessionExist: access token does not exist locally", supertokens-website-ver: "16.0.4"}
com.supertokens {t: "2023-04-17T08:10:31.759Z", message: "getLocalSessionState: returning NOT_EXISTS since frontToken was cleared but lastAccessTokenUpdate exists", supertokens-website-ver: "16.0.4"}
com.supertokens {t: "2023-04-17T08:10:31.759Z", message: "getLocalSessionState: returning NOT_EXISTS since frontToken was cleared but lastAccessTokenUpdate exists", supertokens-website-ver: "16.0.4"}
com.supertokens {t: "2023-04-17T08:10:31.759Z", message: "doesSessionExist: access token does not exist locally", supertokens-website-ver: "16.0.4"}
n

nkshah2

04/17/2023, 8:15 AM
Can you explain what issue you are facing in terms of use case?
d

devertry|deepsheep

04/17/2023, 8:17 AM
I cannot login I am in a paas like heroku that don't have session
it cannot fetch the session ( look like you are based on to
n

nkshah2

04/17/2023, 8:22 AM
Ok just to make sure I understand correctly. - You call the login endpoint and get a valid response - Then you call another endpoint which says you dont have a session?
d

devertry|deepsheep

04/17/2023, 8:23 AM
i try to call the /aith/signin -> it cannot get the session from the backend
I run a python app on clever cloud
n

nkshah2

04/17/2023, 8:23 AM
Can you post the full response of the sign in endpoint? (including headers etc)
d

devertry|deepsheep

04/17/2023, 8:25 AM

https://cdn.discordapp.com/attachments/1097427946853109780/1097437562282455110/Screenshot_20230417_102456.png

js
const session = await Session.doesSessionExist();
when I do this it return me false in the after login
it should be true ?
n

nkshah2

04/17/2023, 8:26 AM
Can you post the config you pass to SuperTokens init on both the frontend and backend?
d

devertry|deepsheep

04/17/2023, 8:27 AM
front end
js
SuperTokens.init({
  enableDebugLogs: true,
  appInfo: {
    appName: "formelegal",
    apiDomain: env.VUE_APP_BASE_URL,
    apiBasePath: "/auth",
  },
  recipeList: [
    Session.init({
      tokenTransferMethod: "header",
    }),
    ThirdPartyEmailPassword.init(),
    EmailPassword.init(),
  ],
})
backend
py
init(
    app_info=InputAppInfo(
        app_name="formelegal",
        api_domain=env.SUPER_TOKEN_API_DOMAIN,
        website_domain=env.SUPER_TOKEN_WEBSITE_DOMAIN,
        api_base_path="/auth",
        website_base_path="/auth"
    ),
    supertokens_config=SupertokensConfig(
        connection_uri=env.SUPER_TOKEN_CONNECTION_URI,
        api_key=env.SUPER_TOKEN_API_KEY
    ),
    framework='fastapi',
    recipe_list=[
        dashboard.init(),
        session.init(get_token_transfer_method=get_token_transfer_method),
        thirdpartyemailpassword.init(
            sign_up_feature=thirdpartyemailpassword.InputSignUpFeature(
                form_fields=[InputFormField(id='firstname'), InputFormField(id='lastname'), InputFormField(id='phone')]
            ),
            override=thirdpartyemailpassword.InputOverrideConfig(
                apis=override_apis
            )
        ),
        emailpassword.init()
    ],
    mode='wsgi'  # use wsgi if you are running using gunicorn
)
n

nkshah2

04/17/2023, 8:28 AM
How have you defined
get_token_transfer_method
?
d

devertry|deepsheep

04/17/2023, 8:28 AM
py

def get_token_transfer_method(req: BaseRequest, for_create_new_session: bool, user_context: Dict[str, Any]):
    # OR use session.init(get_token_transfer_method=lambda *_: "header")
    return "header"
n

nkshah2

04/17/2023, 8:31 AM
Perhaps @porcellus can help better here
d

devertry|deepsheep

04/17/2023, 8:32 AM
sorry I will move back to aws with api gateway
I think its more hassle free
thanks for all and good luck
so it's return me the field but always response false
js
com.supertokens {t: "2023-04-17T09:45:05.479Z", message: "doesSessionExist: access token does not exist locally", supertokens-website-ver: "16.0.4"}
js
com.supertokens {t: "2023-04-17T09:45:05.479Z", message: "getLocalSessionState: returning NOT_EXISTS since frontToken was cleared but lastAccessTokenUpdate exists", supertokens-website-ver: "16.0.4"}
p

porcellus

04/17/2023, 9:52 AM
hi
return me in the field?
d

devertry|deepsheep

04/17/2023, 9:52 AM
try it
js
const session = await Session.doesSessionExist();
it's return me false whathever , but localhost it's ok
I am using vuejs for front end and python for backend
p

porcellus

04/17/2023, 9:56 AM
oh, so it works on localhost?
d

devertry|deepsheep

04/17/2023, 9:57 AM
yess
and http api call
p

porcellus

04/17/2023, 9:58 AM
since you are doing this in serverless, do you have this deployed somewhere I could check it? it may speed things up
d

devertry|deepsheep

04/17/2023, 9:58 AM
in paas
usualy how you deploy super token apps ?
p

porcellus

04/17/2023, 10:01 AM
I'm not sure about statistics, we provide support for self-hosted, serverless, and I think paas shouldn't be any different.
d

devertry|deepsheep

04/17/2023, 10:01 AM
usualy how you user deploy them apps ? 🙂
p

porcellus

04/17/2023, 10:03 AM
Like I said, I'm not sure about stats, I'll ask.
Anyway, can you provide me debug logs made during the login call?
or is there a public link I could check out?
d

devertry|deepsheep

04/17/2023, 10:03 AM
I thnk its my front end
I have no error and all is ok in the logs
p

porcellus

04/17/2023, 10:04 AM
I meant the debug logs on the frontend
d

devertry|deepsheep

04/17/2023, 10:06 AM
js
com.supertokens {t: "2023-04-17T10:05:29.035Z", message: "onUnauthorisedResponse: local session doesn't exist, so removing anti-csrf and sFrontToken", supertokens-website-ver: "16.0.4"}
js
com.supertokens {t: "2023-04-17T10:05:29.033Z", message: "getLocalSessionState: returning NOT_EXISTS since frontToken was cleared but lastAccessTokenUpdate exists", supertokens-website-ver: "16.0.4"}

https://cdn.discordapp.com/attachments/1097427946853109780/1097463376805900288/Screenshot_20230417_120728.png

p

porcellus

04/17/2023, 10:09 AM
there should be a lot of these logs, please either copy the entire text or there is a save as option if you right click the console
that cookie is not set by us.
ok I see
p

porcellus

04/17/2023, 10:13 AM
@rp can answer the deployment question
(I'm checking out your logs)
d

devertry|deepsheep

04/17/2023, 10:14 AM
do i need to be https for production ?
r

rp

04/17/2023, 10:15 AM
> usualy how you user deploy them apps ? For self hosted, Via docker, in ec2 instance. However, using our managed service is simpler
p

porcellus

04/17/2023, 10:20 AM
I'd always recommend https for production, but I don't think it's strictly necessary.
Checking out your logs: your deployed frontend seems to not have the
tokenTransferMethod: "header"
config
d

devertry|deepsheep

04/17/2023, 10:23 AM
it's not insecure ?
p

porcellus

04/17/2023, 10:24 AM
it is in general what I meant is that it's not required by supertokens I think.
d

devertry|deepsheep

04/17/2023, 10:25 AM
I have a problem with same site
ok its my provider with add a cookies
now its strange it refresh everytime the session !
p

porcellus

04/17/2023, 12:18 PM
refresh every time the session? you mean on every page reload?
or do you mean it's continously refreshing?
d

devertry|deepsheep

04/17/2023, 12:23 PM
yes
p

porcellus

04/17/2023, 12:24 PM
which one?
d

devertry|deepsheep

04/17/2023, 12:24 PM
signinUser on session
p

porcellus

04/17/2023, 12:25 PM
I'm not sure what you mean by that
d

devertry|deepsheep

04/17/2023, 12:25 PM
i tell you after
p

porcellus

04/17/2023, 12:44 PM
ok
d

devertry|deepsheep

04/17/2023, 2:38 PM
it does always an event loop
like when you start the login => never stop after and search the token
in the backend
py
INFO:     127.0.0.1:43654 - "POST /auth/session/refresh HTTP/1.1" 200 OK
com.supertokens {"t": "2023-04-17T14:38:48.692Z", "sdkVer": "0.12.6", "message": "middleware: Started", "file": "supertokens.py:458"}

com.supertokens {"t": "2023-04-17T14:38:48.692Z", "sdkVer": "0.12.6", "message": "middleware: requestRID is: session", "file": "supertokens.py:471"}

com.supertokens {"t": "2023-04-17T14:38:48.692Z", "sdkVer": "0.12.6", "message": "middleware: Checking recipe ID for match: dashboard", "file": "supertokens.py:482"}

com.supertokens {"t": "2023-04-17T14:38:48.692Z", "sdkVer": "0.12.6", "message": "middleware: Checking recipe ID for match: session", "file": "supertokens.py:482"}

com.supertokens {"t": "2023-04-17T14:38:48.693Z", "sdkVer": "0.12.6", "message": "middleware: Matched with recipe ID: session", "file": "supertokens.py:504"}

com.supertokens {"t": "2023-04-17T14:38:48.693Z", "sdkVer": "0.12.6", "message": "middleware: Request being handled by recipe. ID is: /session/refresh", "file": "supertokens.py:516"}

com.supertokens {"t": "2023-04-17T14:38:48.693Z", "sdkVer": "0.12.6", "message": "refreshSession: Started", "file": "recipe/session/recipe_implementation.py:492"}

com.supertokens {"t": "2023-04-17T14:38:48.693Z", "sdkVer": "0.12.6", "message": "refreshSession: got refresh token from cookie", "file": "recipe/session/recipe_implementation.py:506"}

com.supertokens {"t": "2023-04-17T14:38:48.694Z", "sdkVer": "0.12.6", "message": "refreshSession: getTokenTransferMethod returned: any", "file": "recipe/session/recipe_implementation.py:515"}

com.supertokens {"t": "2023-04-17T14:38:48.694Z", "sdkVer": "0.12.6", "message": "refreshSession: using cookie transfer method", "file": "recipe/session/recipe_implementation.py:532"}
p

porcellus

04/17/2023, 3:06 PM
event loop? I think there are two issues: 1. You call
doesSessionExist
on every render and getting the result seems to be triggering the render once again 2. For some reason saving the cookies fail. It didn't show in the config you pasted here, but I think you've set something as the
sessionTokenFrontendDomain
that doesn't match the current domain.
d

devertry|deepsheep

04/17/2023, 7:17 PM
I set the headers as bearer => need to set it as cookies again
next week I will look to the sdf why it doesnt set properly when you have nothing into
need to set it again in session.init()
thanks for your help ! 🙂