Thread
#general
    CaptainPhoton

    CaptainPhoton

    3 months ago
    Hi! I'm trying to login with the Google provider and it works, but upon login an error is thrown in the console from supertokens axios: Error: Request failed with status code 400
    r

    rp

    3 months ago
    hey!
    CaptainPhoton

    CaptainPhoton

    3 months ago
    is this a know issue or...?
    r

    rp

    3 months ago
    which version of supertokens-auth-react?
    CaptainPhoton

    CaptainPhoton

    3 months ago
    it's on the backend
    sorry, should have said
    r

    rp

    3 months ago
    whats the response to the /signinup request?
    CaptainPhoton

    CaptainPhoton

    3 months ago
    error: Error: Request failed with status code 400
        at createError (node_modules/supertokens-node/node_modules/axios/lib/core/createError.js:16:15)
        at settle (node_modules/supertokens-node/node_modules/axios/lib/core/settle.js:17:12)
        at IncomingMessage.handleStreamEnd (node_modules/supertokens-node/node_modules/axios/lib/adapters/http.js:269:11)
        at IncomingMessage.emit (node:events:532:35)
        at IncomingMessage.emit (node:domain:475:12)
        at endReadableNT (node:internal/streams/readable:1346:12)
        at processTicksAndRejections (node:internal/process/task_queues:83:21)
    the login works
    but that error is a bit spooky
    r

    rp

    3 months ago
    this can happen if you are calling the signinup API twice - the first one works, whilst the second one fails with this error.
    So you should check the network tab on the frontend to see that this API is called just once (one call to the OPTIONS API, and one to the actual POST API)
    CaptainPhoton

    CaptainPhoton

    3 months ago
    Not calling it twice as far as I know
    okay I'll check
    r

    rp

    3 months ago
    can you confirm though?
    CaptainPhoton

    CaptainPhoton

    3 months ago
    yeah one sec
    Oh yeah, it is called twice 🤔 weird
    r

    rp

    3 months ago
    haha!
    are you using our supertokens-auth-react SDK?
    Or something else?
    CaptainPhoton

    CaptainPhoton

    3 months ago
    yeah
    r

    rp

    3 months ago
    which version of the SDK?
    CaptainPhoton

    CaptainPhoton

    3 months ago
    should be 0.22.3
    but I see there is a new version
    r

    rp

    3 months ago
    0.22.3 should work fine.
    as in it shouldn't call the API twice
    CaptainPhoton

    CaptainPhoton

    3 months ago
    could it be because I have both the SessionAuth wrapper and ThirdPartyPasswordlessAuth in the app?
    r

    rp

    3 months ago
    not really.
    CaptainPhoton

    CaptainPhoton

    3 months ago
    okay good 😄
    I'm using React 17 and not in strict mode, so it should not call effects twice
    r

    rp

    3 months ago
    hmm. we are compatible with react 18 anyway
    so really strange that it's calling twice
    does it happen all the time?
    CaptainPhoton

    CaptainPhoton

    3 months ago
    yeah always when logging in with Google
    r

    rp

    3 months ago
    and other providers?
    CaptainPhoton

    CaptainPhoton

    3 months ago
    I just checked, and the two calls happen during the supertokens flow before coming back to my app
    don't have any others integrated atm except for facebook, and I don't have or want an fb account so... 😄
    r

    rp

    3 months ago
    ok fair.
    perhaps @porcellus can help with this
    are you rendering the callback screen yourself? or using the default route?
    CaptainPhoton

    CaptainPhoton

    3 months ago
    default route
    Hopefully Porcellus can help! And I gotta say, the support here is phenomenal. I'll ask my client if we can do some kind of contribution at some point
    r

    rp

    3 months ago
    thanks!!
    CaptainPhoton

    CaptainPhoton

    3 months ago
    thank you 😄
    r

    rp

    3 months ago
    is it possible for you to use react 18 and check it out? Does it still call it twice?
    CaptainPhoton

    CaptainPhoton

    3 months ago
    I can try
    r

    rp

    3 months ago
    can switch to that, try and and switch back to 17
    CaptainPhoton

    CaptainPhoton

    3 months ago
    yep same result
    I'll keep 18 😄
    r

    rp

    3 months ago
    hmm that's really strange
    are you doing anything custom at all around this screen or component?
    CaptainPhoton

    CaptainPhoton

    3 months ago
    no 😄
    SuperTokens.init({
        appInfo: {
          appName: REACT_APP_AUTH_NAME,
          apiDomain: REACT_APP_AUTH_API_DOMAIN,
          websiteDomain: REACT_APP_AUTH_WEB_DOMAIN,
          apiBasePath: REACT_APP_AUTH_API_PATH,
          websiteBasePath: REACT_APP_AUTH_WEB_PATH
        },
        recipeList: [
          ThirdPartyPasswordless.init({
            contactMethod: 'EMAIL_OR_PHONE',
            emailVerificationFeature: {
              mode: 'REQUIRED'
            },
            signInUpFeature: {
              defaultCountry: 'FI',
              providers: [ThirdPartyPasswordless.Google.init(), ThirdPartyPasswordless.Facebook.init()]
            }
          }),
          Session.init()
        ]
      })
    this is my init
    then I have the Auth wrappers and the SuperTokens.getRoutingComponent()
    r

    rp

    3 months ago
    that's pretty standard
    CaptainPhoton

    CaptainPhoton

    3 months ago
    yeah
    r

    rp

    3 months ago
    can you open an issue about this on our auth-react SDK?
    Will have a look
    CaptainPhoton

    CaptainPhoton

    3 months ago
    actually nevermind
    sorry 😄 I removed stuff from the code
    I had used
    let { doesSessionExist } = useSessionContext()
    and when the session came into existence, I fetch user data from the backend. I commented that out and it stopped calling twice
    Okay, I had just overcomplicated things. TBH this code was from the auth0 days and I just quickly converted it to check the session from supertokens instead
    r

    rp

    3 months ago
    hmm so is this sorted out?
    CaptainPhoton

    CaptainPhoton

    3 months ago
    it seems so!
    oh damn did I put this in general? sorry 😄
    you can delete the thread if you want
    r

    rp

    3 months ago
    no thats fine! don't worry about it