https://supertokens.com/ logo
Title
a

aarron28

02/17/2023, 10:28 AM
Hi, I have a simple web application and I am trying to perform login and get session information like getting the access token When I try to run the code below, it show error which is no instance of session found. Make sure to call session.init method. How should I be logging in and getting the session object? session_provider :async() => { supertokens.init({ appInfo: { apiDomain: "https://aarron28.com", apiBasePath: "/auth", appName: "Test App" }, recipeList: [ supertokensSession.init({ tokenTransferMethod: "header" // or "cookie" }), supertokensSession.init(), supertokensEmailPassword.init(), ], }); var aaa = await supertokensEmailPassword.signIn({ "formFields": [{ "id": "email", "value": "lucas333" }, { "id": "password", "value": "pas123" }] }); supertokensSession.getAccessToken(); return aaa; }
r

rp

02/17/2023, 10:30 AM
hey @aarron28 You need to make sure to call supertokens.init on every page (re)load, and also you have initialised supertokensSession twice.
a

aarron28

02/17/2023, 10:32 AM
Thanks @rp I am actually just running this function on a single page. typo on the supertokensSession, I removed one of it and it still is the same.
r

rp

02/17/2023, 10:33 AM
Does a call to
supertokensEmailPassword.signIn
work fine?
a

aarron28

02/17/2023, 10:33 AM
yes it does
It returns and Ok with the user ID
its just supertokenssSession.getAccessToken(0 that does not run
or any supertokensSession function for that matter
r

rp

02/17/2023, 10:34 AM
What about if you run
supertokensSession.doesSessionExist()
a

aarron28

02/17/2023, 10:34 AM
Nope, same, "No instanec of Session found....."
r

rp

02/17/2023, 10:35 AM
ok we will check this out. Might be a bug in our SDK. @nkshah2 can help here.
a

aarron28

02/17/2023, 10:36 AM
Just to let you know that we are using this scripts
n

nkshah2

02/17/2023, 10:45 AM
Hey, so I set up with a simple html page and the code works fine for me. Can you verify that your
session_provider
function gets called on page load for all pages you are using supertokens in? Heres my code:
html
<html>
    <head>
        <script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js/bundle/website.js"></script>
        <script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js/bundle/supertokens.js"></script>
        <script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js/bundle/session.js"></script>
        <script src="https://cdn.jsdelivr.net/gh/supertokens/supertokens-web-js/bundle/emailpassword.js"></script>
    </head>
    <body>
        <script>
            supertokens.init({
                appInfo: {
                    apiDomain: "http://localhost:3001",
                    apiBasePath: "/auth",
                    appName: "Test",
                },
                recipeList: [
                    supertokensSession.init({
                        tokenTransferMethod: "header"
                    }),
                    supertokensEmailPassword.init(),
                ],
            });

            async function doesSessionExist() {
                console.log(await supertokensSession.doesSessionExist())
            }
        </script>

        <button onclick="doesSessionExist()">Check session</button>
    </body>
</html>
a

aarron28

02/20/2023, 2:26 AM
I have tried the code it returns this error
n

nkshah2

02/20/2023, 2:56 AM
What’s the value of session token frontend domain you are passing?
a

aarron28

02/20/2023, 3:26 AM
I am not passing anything. I just want to get the session token from supertokens
n

nkshah2

02/20/2023, 3:29 AM
Can you explain the stack you’re using? Is it a plain html site or are you using a framework?
a

aarron28

02/20/2023, 3:30 AM
It is a plain html
n

nkshah2

02/20/2023, 3:34 AM
And you’re serving the index.html file using serve or something right? Not just opening the html file directly?
a

aarron28

02/20/2023, 3:36 AM
Yes I am running in live server
n

nkshah2

02/20/2023, 3:37 AM
Might be easier to debug this on call
a

aarron28

02/20/2023, 3:46 AM
Can we do it around 4 PM (Malaysia time)?
n

nkshah2

02/20/2023, 5:40 AM
That works, if you DM me your email I can drop an invite
a

aarron28

02/20/2023, 5:49 AM
aarron.michael@strellagroup.com
n

nkshah2

02/20/2023, 5:50 AM
Sent you an invite
a

aarron28

02/20/2023, 6:15 AM
Can we make the meeting at 4PM (Malaysia Time)?
n

nkshah2

02/20/2023, 6:45 AM
Hi, seems you declined the invite. Did you figure out what was wrong?
a

aarron28

02/20/2023, 6:49 AM
The time you mentioned there was 9 pm (malaysia time) which i am not available Can me meet at 4pm Malaysia time
n

nkshah2

02/20/2023, 6:51 AM
Ah my mistake, would 7pm Malaysia time work for you? I'm not available before then sadly
a

aarron28

02/20/2023, 6:57 AM
I am not available after 7pm today Can be make it tomorrow onwards?
n

nkshah2

02/20/2023, 6:57 AM
Sure that works, let me know what time is good for you tomorrow
a

aarron28

02/20/2023, 7:17 AM
Can meet at 2pm (Malaysia Time) tomorrow ?
Which should be 11:30 AM (Kolkata Time)
n

nkshah2

02/20/2023, 7:35 AM
Sure that works, ill send an invite
a

aarron28

02/20/2023, 7:47 AM
Ok nice Thanks
n

nkshah2

02/21/2023, 6:01 AM
Hi @aarron28 , Im on the call (the link is in the invite).
a

aarron28

02/21/2023, 6:22 AM
Once I updated the supertokens-python to 0.12.1, I am able to get the token. Thanks for the help.
n

nkshah2

02/21/2023, 6:22 AM
Happy to help