0

I have to authenticate phone number using firebase otp in my NodeJS express API . I'm already using mongo dB for storing data also i need to add firebase . how i add firebase to my NodeJS app and send otp to that number .

Dharmaraj
  • 47,845
  • 8
  • 52
  • 84
ajay
  • 3
  • 1
  • 3

1 Answers1

4

There is no method in Firebase Admin SDK to send verification SMS. Only the users (using Client SDK) can request it. You would have to implement a custom auth flow if you want to send SMS from your server and send messages yourself using services like Twilio.

It's more like having a custom authentication system but then you use Custom Tokens to login user using Firebase after you've authenticated them.

To summarize the auth flow:

  1. Send SMS to user from your server (and store the code in database)
  2. When user enters the code, verify it and generate a custom token using Admin SDK
  3. Send the custom token back and log in user using Firebase
Dharmaraj
  • 47,845
  • 8
  • 52
  • 84