Hi, I have a simple web application and I am tryin...
# support-questions-legacy
a
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
hey @aarron28_ You need to make sure to call supertokens.init on every page (re)load, and also you have initialised supertokensSession twice.
a
Thanks @rp_st 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
Does a call to
supertokensEmailPassword.signIn
work fine?
a
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
What about if you run
supertokensSession.doesSessionExist()
a
Nope, same, "No instanec of Session found....."
r
ok we will check this out. Might be a bug in our SDK. @nkshah2 can help here.
a
Just to let you know that we are using this scripts
n
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:
Copy 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
I have tried the code it returns this error
n
What’s the value of session token frontend domain you are passing?
a
I am not passing anything. I just want to get the session token from supertokens
n
Can you explain the stack you’re using? Is it a plain html site or are you using a framework?
a
It is a plain html
n
And you’re serving the index.html file using serve or something right? Not just opening the html file directly?
a
Yes I am running in live server
n
Might be easier to debug this on call
a
Can we do it around 4 PM (Malaysia time)?
n
That works, if you DM me your email I can drop an invite
a
aarron.michael@strellagroup.com
n
Sent you an invite
a
Can we make the meeting at 4PM (Malaysia Time)?
n
Hi, seems you declined the invite. Did you figure out what was wrong?
a
The time you mentioned there was 9 pm (malaysia time) which i am not available Can me meet at 4pm Malaysia time
n
Ah my mistake, would 7pm Malaysia time work for you? I'm not available before then sadly
a
I am not available after 7pm today Can be make it tomorrow onwards?
n
Sure that works, let me know what time is good for you tomorrow
a
Can meet at 2pm (Malaysia Time) tomorrow ?
Which should be 11:30 AM (Kolkata Time)
n
Sure that works, ill send an invite
a
Ok nice Thanks
n
Hi @aarron28_ , Im on the call (the link is in the invite).
a
Once I updated the supertokens-python to 0.12.1, I am able to get the token. Thanks for the help.
n
Happy to help
16 Views