supabase-js icon indicating copy to clipboard operation
supabase-js copied to clipboard

`auth.updateUser()` kept sending the same OTP code when updating Phone provider

Open JUDE-EQ opened this issue 1 year ago • 5 comments

Hey guys, I have an Issue with auth.updateUser() sending OTP code in phone

So in my app i have a multi-step and im trying to this so in for example in step-1, im signing up user with their email on my app with this

  const sendEmailOtp = async () => {
    const { data, error } = await supabase.auth.signInWithOtp({
      email,
    })
    return data
  }

then verify it... and hop on to the step-2 that contains phone number, for the phone number im using updateUser() so that they can have both provider email & phone check code below

    const { data, error } = await supabase.auth.updateUser({
      phone,
    }) 

And it successfully sends the OTP to phone number, but it kept sending the same OTP code over and over again, and once I try to verify it, it just returns this 403 forbidden error

AuthApiError: Token has expired or is invalid
    at handleError (fetch.js:74:11)
    at async _handleRequest (fetch.js:120:9)
    at async _request (fetch.js:99:18)
    at async SupabaseAuthClient.verifyOtp (GoTrueClient.js:564:37)
    at async verifyPhoneOtp (page.tsx:62:29)

I'm using "@supabase/supabase-js": "^2.39.1",

JUDE-EQ avatar Aug 27 '24 16:08 JUDE-EQ

This is happening to me too. I have an existing user i'm trying to add a phone number to their account using updateUser. Twilio sends the SMS and it always says the token is expired or invalid.

k2xl avatar Sep 19 '24 15:09 k2xl

this seems like to be a bug from their end, i wrote this issue in supabase discord and this guy also having the same problem and says image

JUDE-EQ avatar Sep 19 '24 15:09 JUDE-EQ

FWIW I figured it out - For updateUser pass in the type "phone_change"

k2xl avatar Sep 20 '24 19:09 k2xl

@k2xl, what supabase-js version are you using? adding type: phone_change does not work for me. Maybe we have different supabase-js version?

im using this version on my app

    "@supabase/ssr": "^0.0.10",
    "@supabase/supabase-js": "^2.39.1",

JUDE-EQ avatar Nov 19 '24 16:11 JUDE-EQ

oh nevermind it works, just something wrong with my config. haha thanks a ton dude @k2xl

JUDE-EQ avatar Nov 19 '24 18:11 JUDE-EQ

This issue has been automatically marked as stale because it has not had any activity for 1 year. It will be closed in 6 months if no further activity occurs. If this issue is still relevant, please comment to keep it open.

github-actions[bot] avatar Nov 23 '25 00:11 github-actions[bot]