https://supertokens.com/ logo
c

CaptainPhoton

06/20/2022, 4:19 PM
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

06/20/2022, 4:19 PM
hey!
c

CaptainPhoton

06/20/2022, 4:19 PM
is this a know issue or...?
r

rp

06/20/2022, 4:19 PM
which version of supertokens-auth-react?
c

CaptainPhoton

06/20/2022, 4:20 PM
it's on the backend
sorry, should have said
r

rp

06/20/2022, 4:20 PM
whats the response to the /signinup request?
c

CaptainPhoton

06/20/2022, 4:21 PM
Copy code
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

06/20/2022, 4:22 PM
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)
c

CaptainPhoton

06/20/2022, 4:22 PM
Not calling it twice as far as I know
okay I'll check
r

rp

06/20/2022, 4:22 PM
can you confirm though?
c

CaptainPhoton

06/20/2022, 4:22 PM
yeah one sec
Oh yeah, it is called twice 🤔 weird
r

rp

06/20/2022, 4:24 PM
haha!
are you using our supertokens-auth-react SDK?
Or something else?
c

CaptainPhoton

06/20/2022, 4:24 PM
yeah
r

rp

06/20/2022, 4:24 PM
which version of the SDK?
c

CaptainPhoton

06/20/2022, 4:25 PM
should be 0.22.3
but I see there is a new version
r

rp

06/20/2022, 4:25 PM
0.22.3 should work fine.
as in it shouldn't call the API twice
c

CaptainPhoton

06/20/2022, 4:26 PM
could it be because I have both the SessionAuth wrapper and ThirdPartyPasswordlessAuth in the app?
r

rp

06/20/2022, 4:27 PM
not really.
c

CaptainPhoton

06/20/2022, 4:27 PM
okay good 😄
I'm using React 17 and not in strict mode, so it should not call effects twice
r

rp

06/20/2022, 4:28 PM
hmm. we are compatible with react 18 anyway
so really strange that it's calling twice
does it happen all the time?
c

CaptainPhoton

06/20/2022, 4:29 PM
yeah always when logging in with Google
r

rp

06/20/2022, 4:29 PM
and other providers?
c

CaptainPhoton

06/20/2022, 4:30 PM
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

06/20/2022, 4:31 PM
ok fair.
perhaps @porcellus can help with this
are you rendering the callback screen yourself? or using the default route?
c

CaptainPhoton

06/20/2022, 4:32 PM
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

06/20/2022, 4:33 PM
thanks!!
c

CaptainPhoton

06/20/2022, 4:33 PM
thank you 😄
r

rp

06/20/2022, 4:35 PM
is it possible for you to use react 18 and check it out? Does it still call it twice?
c

CaptainPhoton

06/20/2022, 4:36 PM
I can try
r

rp

06/20/2022, 4:36 PM
can switch to that, try and and switch back to 17
c

CaptainPhoton

06/20/2022, 4:38 PM
yep same result
I'll keep 18 😄
r

rp

06/20/2022, 4:38 PM
hmm that's really strange
are you doing anything custom at all around this screen or component?
c

CaptainPhoton

06/20/2022, 4:38 PM
no 😄
Copy code
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

06/20/2022, 4:40 PM
that's pretty standard
c

CaptainPhoton

06/20/2022, 4:40 PM
yeah
r

rp

06/20/2022, 4:40 PM
can you open an issue about this on our auth-react SDK?
Will have a look
c

CaptainPhoton

06/20/2022, 4:44 PM
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

06/20/2022, 4:55 PM
hmm so is this sorted out?
c

CaptainPhoton

06/20/2022, 4:56 PM
it seems so!
oh damn did I put this in general? sorry 😄
you can delete the thread if you want
r

rp

06/20/2022, 4:57 PM
no thats fine! don't worry about it