auth icon indicating copy to clipboard operation
auth copied to clipboard

Using custom (Unlimited) SMS Provider for sending OTP

Open novanda1 opened this issue 3 years ago • 10 comments

Feature request

Currently, there is just a few SMS Provider, Twilio and Messagebird but they are expensive for my country, and there is a local SMS Provider that is 500%++ cheaper.

And I believe there is a lot of SMS Provider that cheaper in every country.

https://github.com/supabase/gotrue-js/issues/356

Describe the solution you'd like

Add option in body request that gotrue didn't send the OTP and just give back the OTP code after saving it on the database.

By that, I can use any SMS Provider to send the OTP code, or even I don't send it via SMS, maybe Whatsapp, or anything else.

For example:

curl -X POST 'https://tqfkjdmpohkqylveukuhsy.supabase.net/auth/v1/otp' \
-H "apikey: <SERVICE_KEY>" \
-H "Content-Type: application/json" \
-d '{
  "phone": "123123123123", 
  "send_otp": "false"
}'

{"otp_code":"897514"}

Describe alternatives you've considered

Maybe the API that can write the confirmation_token

curl -X POST 'https://tqfkjdmpohkqylveukuhsy.supabase.net/auth/v1/confirmation_token' \
-H "apikey: <SERVICE_KEY>" \
-H "Content-Type: application/json" \
-d '{
  "phone": "123123123123", 
  "otp":"<RANDOM>"
}'

{"success":"true"}

No need to return an OTP code, since the OTP is created on my end.

Additional context

novanda1 avatar Feb 15 '22 01:02 novanda1

Hi, is there a progress here? Really need this feature. Twilio costs 0.2 usd for single sms in my country

myemuk avatar Aug 18 '22 10:08 myemuk

Hey @myemuk, I've already created a PR for this (#558). In the meantime if you're self-hosting you can use my fork which supports using a custom SMS gateway.

mamousavi avatar Aug 19 '22 12:08 mamousavi

@mamousavi , thanks. Hopefully it will be soon merged

myemuk avatar Aug 19 '22 12:08 myemuk

If you need a quick fix just create psql function to duplicate auth.users to public.user and create psql trigger to run the function each new user signup.

then use RLS (Row Level Security) on your public.users.

novanda1 avatar Aug 19 '22 13:08 novanda1

Any progress here?

myemuk avatar Dec 27 '22 07:12 myemuk

A suggestion we choose the provider that best serves us, in my case I want to be able to send the code via whatsapp api.

An example is that the subbase generates the token and returns it to us and we send the token via the whatsApp API, sms or whichever provider we want, and the user inserting the right token validates the subbase

eduardohr-muniz avatar Apr 12 '23 14:04 eduardohr-muniz

It would be nice to be able to send SMS via Google Cloud's provider. You get 10,000 successful auths/month for free and it's pretty much the only viable option for many indie developers. I believe many developer decide to stay in Firebase because of that.

angelprzz avatar May 04 '23 10:05 angelprzz

It's 2024, any progress here at all?

elcharitas avatar Feb 28 '24 00:02 elcharitas

I don’t know about progress, but I had to go to edge function which sends sms otp code via my favorite provider and saves this token to supabase for later. So it can be verified with standard functionality.

myemuk avatar Feb 29 '24 09:02 myemuk

Is there a workaround on how to do it?

MJUrian-Learner avatar Jul 16 '24 14:07 MJUrian-Learner

Hey all,

Thanks for patiently waiting. We've recently released the send sms hook

Which should allow you to do this. Please give it a spin

Going to close for now. but don't hesitate to reach us if there are issues

J0 avatar Aug 26 '24 22:08 J0