auth
auth copied to clipboard
Using custom (Unlimited) SMS Provider for sending OTP
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
Hi, is there a progress here? Really need this feature. Twilio costs 0.2 usd for single sms in my country
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 , thanks. Hopefully it will be soon merged
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
.
Any progress here?
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
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.
It's 2024, any progress here at all?
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.
Is there a workaround on how to do it?
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