https://supertokens.com/ logo
n

nazzrrg

05/02/2022, 10:25 PM
Fair, but it fails on me with the cookies
p

porcellus

05/02/2022, 10:26 PM
I'm happy to help if you can elaborate a bit more 🙂
n

nazzrrg

05/02/2022, 10:31 PM
Sure. I followed the thirdparty auth recipe, as a result I have a sAccessToken and a sIdRefreshToken. However when I call supertokens.doesSessionExist() or attemptRefreshingSession() they both result in a false value
I import supertokens-website into html and call the init function prior
p

porcellus

05/02/2022, 10:33 PM
but you don't have
sFrontToken
and
sIRTFrontend
?
n

nazzrrg

05/02/2022, 10:33 PM
Copy code
sIRTFrontend
that one I do. value is remove
p

porcellus

05/02/2022, 10:36 PM
yeah, that's the issue
are you using axios?
n

nazzrrg

05/02/2022, 10:38 PM
no, plain JS
p

porcellus

05/02/2022, 10:38 PM
and fetch or XMLHTTPRequest?
n

nazzrrg

05/02/2022, 10:38 PM
fetch
I mean I am somewhat new to js and the init for supertokens is in the file different to the one I am checking for session in, but afaik it should not be the issue
p

porcellus

05/02/2022, 10:42 PM
it should be fine as long as the init happens before the fetch.
an easy way to check is to put "console.log(fetch)" just before you actually call the fetch
if it says
ƒ fetch() { [native code] }
or something like this the init didn't actually go through
n

nazzrrg

05/02/2022, 10:46 PM
Copy code
if (await supertokens.doesSessionExist()) {
            console.log("123");
}
Thats what comes up false
as an example
cookies present
p

porcellus

05/02/2022, 10:47 PM
oh right. can you try logging in again an see what cookies are set?
you have all 4?
n

nazzrrg

05/02/2022, 10:48 PM
I do not have
sFrontToken
p

porcellus

05/02/2022, 10:49 PM
how are you logging in?
n

nazzrrg

05/02/2022, 10:49 PM
google thirdparty
p

porcellus

05/02/2022, 10:50 PM
I meant in your code. Do you have a repo I could check out?
n

nazzrrg

05/02/2022, 10:52 PM
Private as a uni requirement. I can send it all here. There isn't much
p

porcellus

05/02/2022, 10:52 PM
that works for me.
n

nazzrrg

05/02/2022, 10:53 PM
Copy code
const response = await fetch("http://localhost:1337/api/auth/authorisationurl?thirdPartyId=google",
            {
                method: "GET",
                headers: {
                    rid: "thirdparty"
                }
            }
        );
        let urlObj = new URL((await response.json())["url"])
        urlObj.searchParams.append("redirect_uri", "http://localhost:1337/auth/callback/google");
        let url = urlObj.toString();
        window.location.replace(url);
```let code = new URL(window.location.href).searchParams.get('code'); const response = await fetch("http://localhost:1337/api/auth/signinup", { method: "POST", headers: { "rid": "thirdparty", "Content-Type": "application/json" }, body: JSON.stringify({ code, redirectURI: "http://localhost:1337/auth/callback/google", thirdPartyId: "google" }) }); window.location.replace("http://localhost:1337/page");```step 2
that should be an mre
removed logs and a request to my api to create own user representation
p

porcellus

05/02/2022, 10:58 PM
So then what you should check is if the supertokens init happened before these fetches. Like I said an easy way is to log the value of fetch before calling it.
I think the fetch in step 2 may be called before the SDK is initialized
n

nazzrrg

05/02/2022, 11:00 PM
do I just log the promise I get from fetch to see whats inside?
p

porcellus

05/02/2022, 11:00 PM
no, the fetch function itself.
n

nazzrrg

05/02/2022, 11:00 PM
Or how exactly do I log fetch
ok
p

porcellus

05/02/2022, 11:01 PM
console.log(fetch)
if it says
ƒ fetch() { [native code] }
or something like this the init didn't happen
n

nazzrrg

05/02/2022, 11:01 PM
It did not
Do I need an extra init on my callback page then?
p

porcellus

05/02/2022, 11:02 PM
Extra init?
n

nazzrrg

05/02/2022, 11:03 PM
I mean what exactly happens when I call it? Can I simply call it twice?
p

porcellus

05/02/2022, 11:04 PM
The second init call throws.
It should be run exactly once per page reload
n

nazzrrg

05/02/2022, 11:05 PM
it will be ok then
Yes, I do have
sFrontToken
now
And the session now exists
Thank You!
p

porcellus

05/02/2022, 11:07 PM
Happy to help 🙂
16 Views