Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

fix: add the whatsapp otp method

[email protected]4f470c186563
diff --git a/apps/docs/pages/guides/auth/phone-login/twilio.mdx b/apps/docs/pages/guides/auth/phone-login/twilio.mdx
index b286ca3faab..3cb789e1793 100644
--- a/apps/docs/pages/guides/auth/phone-login/twilio.mdx
+++ b/apps/docs/pages/guides/auth/phone-login/twilio.mdx
@@ -297,6 +297,41 @@ The user does not have a password therefore will need to sign in via this method
## WhatsApp OTP Logins
+In some cases, you may wish to use WhatsApp as a delivery channel instead. Here are some examples our users have cited:
+
+- You want higher deliverability
+- You wish for a secure channel with end to end encryption
+- Your users mostly use WhatsApp as a messaging platform
+
+To make use of WhatsApp OTP, please completed the following steps:
+
+- Upgrade Twilio account to a paid account
+- Please go through the [Twilio self sign up guide for WhatsApp](https://www.twilio.com/docs/whatsapp/self-sign-up)
+- Submit a template via the [Twilio Guide For Submitting WhatsApp templates](https://www.twilio.com/docs/whatsapp/tutorial/send-whatsapp-notification-messages-templates#creating-message-templates-and-submitting-them-for-approval).
+
+```js
+let { user, error } = await supabase.auth.signInWithOtp({
+ phone: '+13334445555',
+ channel: 'whatsapp',
+})
+```
+
+```js
+// After receiving a SMS with a OTP.
+const { data, error } = await supabase.auth.signInWithPassword({
+ phone: '+13334445555',
+ channel: 'whatsapp'
+ password: 'testsupabasenow',
+})
+
+```
+
+<Caution>
+
+The message template submitted to Twilio must exactly match the message you enter on the Supabase dashboard.
+
+</Caution>
+
Pre-requisites:
- Please go through the Setting up a Whatsapp Verified Sender guide by Twilio
- Please [submit WhatsApp message templates to Twilio for verification](https://www.twilio.com/docs/whatsapp/tutorial/send-whatsapp-notification-messages-templates#creating-message-templates-and-submitting-them-for-approval)
diff --git a/spec/common-client-libs-sections.json b/spec/common-client-libs-sections.json
index b77ac83e9f2..f88a1faddcf 100644
--- a/spec/common-client-libs-sections.json
+++ b/spec/common-client-libs-sections.json
@@ -422,6 +422,13 @@
"product": "auth",
"type": "function"
},
+ {
+ "id": "sign-in-with-whatsapp-otp",
+ "title": "Sign in a user through WhatsApp",
+ "slug": "auth-signinwithwhatsappotp",
+ "product": "auth",
+ "type": "function"
+ },
{
"id": "sign-out",
"title": "Sign out a user",
@@ -869,4 +876,4 @@
}
]
}
-]
\ No newline at end of file
+]
diff --git a/spec/supabase_js_v2.yml b/spec/supabase_js_v2.yml
index 3e63efe3756..99969942e9d 100644
--- a/spec/supabase_js_v2.yml
+++ b/spec/supabase_js_v2.yml
@@ -258,6 +258,18 @@ functions:
phone: '+13334445555',
})
```
+ - id: sign-in-with-whatsapp-otp
+ name: Sign in with WhatsApp OTP
+ isSpotlight: false
+ description: The user will be sent a WhatsApp message which contains a OTP. By default, a given user can only request a OTP once every 60 seconds. Note that a user
+ will need to have a Twilio linked WhatsApp account in order to use this feature.
+ code: |
+ ```js
+ const { data, error } = await supabase.auth.signInWithOtp({
+ phone: '+13334445555',
+ channel: 'whatsapp'
+ })
+ ```
- id: sign-in-with-oauth
title: 'signInWithOAuth()'
$ref: '@supabase/gotrue-js.GoTrueClient.signInWithOAuth'