Fair, but it fails on me with the cookies
# general
n
Fair, but it fails on me with the cookies
p
I'm happy to help if you can elaborate a bit more 🙂
n
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
but you don't have
sFrontToken
and
sIRTFrontend
?
n
Copy code
sIRTFrontend
that one I do. value is remove
p
yeah, that's the issue
are you using axios?
n
no, plain JS
p
and fetch or XMLHTTPRequest?
n
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
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
Copy code
if (await supertokens.doesSessionExist()) {
            console.log("123");
}
Thats what comes up false
as an example
cookies present
p
oh right. can you try logging in again an see what cookies are set?
you have all 4?
n
I do not have
sFrontToken
p
how are you logging in?
n
google thirdparty
p
I meant in your code. Do you have a repo I could check out?
n
Private as a uni requirement. I can send it all here. There isn't much
p
that works for me.
n
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
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
do I just log the promise I get from fetch to see whats inside?
p
no, the fetch function itself.
n
Or how exactly do I log fetch
ok
p
console.log(fetch)
if it says
Æ’ fetch() { [native code] }
or something like this the init didn't happen
n
It did not
Do I need an extra init on my callback page then?
p
Extra init?
n
I mean what exactly happens when I call it? Can I simply call it twice?
p
The second init call throws.
It should be run exactly once per page reload
n
it will be ok then
Yes, I do have
sFrontToken
now
And the session now exists
Thank You!
p
Happy to help 🙂
17 Views