how to do SMS OTP verification service in backend with node js

1.1k Views Asked by At

I am writing a backend with node js. This backend will serve both the mobile side and the web side. Now I have a task like this: I want to write an sms verification service. When a request is made to this service, whether it is from the mobile side or from the web side, it should send an OTP code to the specified phone number and verify it.

I thought that I could do this with firebase, but it didn't happen, because since Firebas itself is a BaaS, it seemed more logical to use firebase on the front side. but i want to write it a service on backend side. Also, I tried to do it with a modem (I was also sending sms with a modem and verifying), but since my service will run on servers like a VPS, I can't put a modem there. that's why this doesn't happen. If you have any ideas, please let me know.

1

There are 1 best solutions below

3
Frank van Puffelen On

Firebase Authentication can only send SMS messages to the currently signed in user, and only from its client-side SDKs. Firebase does not have any built-in feature to allow you to send SMS messages from the server.

Since connecting to your own device to send the SMS is not an option as you said, the most common solution would be to use another 3rd party SMS sending service, such as Twilio or Vonage. You'd then call their API from your Node.js code to send the SMS messages with an OTP.