nazzrrg

    nazzrrg

    4 months ago
    Fair, but it fails on me with the cookies
    p

    porcellus

    4 months ago
    I'm happy to help if you can elaborate a bit more 🙂
    nazzrrg

    nazzrrg

    4 months ago
    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

    4 months ago
    but you don't have
    sFrontToken
    and
    sIRTFrontend
    ?
    nazzrrg

    nazzrrg

    4 months ago
    sIRTFrontend
    that one I do. value is remove
    p

    porcellus

    4 months ago
    yeah, that's the issue
    are you using axios?
    nazzrrg

    nazzrrg

    4 months ago
    no, plain JS
    p

    porcellus

    4 months ago
    and fetch or XMLHTTPRequest?
    nazzrrg

    nazzrrg

    4 months ago
    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

    4 months ago
    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
    nazzrrg

    nazzrrg

    4 months ago
    if (await supertokens.doesSessionExist()) {
                console.log("123");
    }
    Thats what comes up false
    as an example
    cookies present
    p

    porcellus

    4 months ago
    oh right. can you try logging in again an see what cookies are set?
    you have all 4?
    nazzrrg

    nazzrrg

    4 months ago
    I do not have
    sFrontToken
    p

    porcellus

    4 months ago
    how are you logging in?
    nazzrrg

    nazzrrg

    4 months ago
    google thirdparty
    p

    porcellus

    4 months ago
    I meant in your code. Do you have a repo I could check out?
    nazzrrg

    nazzrrg

    4 months ago
    Private as a uni requirement. I can send it all here. There isn't much
    p

    porcellus

    4 months ago
    that works for me.
    nazzrrg

    nazzrrg

    4 months ago
    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

    4 months ago
    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
    nazzrrg

    nazzrrg

    4 months ago
    do I just log the promise I get from fetch to see whats inside?
    p

    porcellus

    4 months ago
    no, the fetch function itself.
    nazzrrg

    nazzrrg

    4 months ago
    Or how exactly do I log fetch
    ok
    p

    porcellus

    4 months ago
    console.log(fetch)
    if it says
    ƒ fetch() { [native code] }
    or something like this the init didn't happen
    nazzrrg

    nazzrrg

    4 months ago
    It did not
    Do I need an extra init on my callback page then?
    p

    porcellus

    4 months ago
    Extra init?
    nazzrrg

    nazzrrg

    4 months ago
    I mean what exactly happens when I call it? Can I simply call it twice?
    p

    porcellus

    4 months ago
    The second init call throws.
    It should be run exactly once per page reload
    nazzrrg

    nazzrrg

    4 months ago
    it will be ok then
    Yes, I do have
    sFrontToken
    now
    And the session now exists
    Thank You!
    p

    porcellus

    4 months ago
    Happy to help 🙂