supabase / supabase

The open source Firebase alternative. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
https://supabase.com
Apache License 2.0
71.46k stars 6.82k forks source link

Supabase Error sending confirmation OTP to provider. Invalid message-capable Twilio phone number for this destination #28770

Closed haocloo closed 3 weeks ago

haocloo commented 3 weeks ago

Hi, I'm trying to send the OTP to the phone number but I'm stucked at this error supabase Error sending confirmation OTP to provider: The \'From\' phone number provided (+125xxxxxxxx) is not a valid message-capable Twilio phone number for this destination. I thought it was an error related to Twilio Message Service SID so I have tried using the Service SSID (VAxxxxxxx) and also the My Twilio phone number (+125xxxxxxxx) but to no avail. I'm using a trial account and the phone number I used to test is a verified phone number in my twilio account.

My supabase settings:

This is the code I'm using in NextJS 14.2.5

"use server";

// necessary imports

export async function sendOTP(
  formState: FormState,
  formData: FormData
): Promise<any> {
  try {
    const { phone } = phoneSchema.parse({ phone: formData.get("phone") });
    // console.log(phone);
    const supabase = createClient();

    const { error } = await supabase.auth.signInWithOtp({
      phone: "6" + phone, // example: 60123456789
      options: {
        channel: "sms",
      },
    });
    // console.log(error);
    if (error) throw error;
    return toFormState("SUCCESS", "OTP sent");
  } catch (error) {
    console.log(error);
    return fromErrorToFormState(error);
  }
}
haocloo commented 3 weeks ago

In Supabase auth providers settings,