Home > database >  Can I send custom OTP in Firebase Phone Authentication?
Can I send custom OTP in Firebase Phone Authentication?

Time:07-01

I would like to create asp.net user and use Firebase Phone Authentication to verify phone number. is it possible to send a custom code generated on server side to send as OTP to Firebase Authentication User?

Currently my app calls create user API after Phone Authentication is Completed.(Which means anyone can directly call Create User API with tools like Postman). I need a Custom OTP to be stored on my Server side database table and send to user at least when user tries to reset their database, Kindly Help

CodePudding user response:

Folloing point's will resolve your issue

  1. Store OTP in Database with new GUID() with verified status and OTP expire time;
  2. send that OTP and ID while creating user with in different properties
  3. Verify the OTP with ID and Status and Expire time
  4. If It is valid create the user Else don't create the user

sample table structure

CREATE TABLE PhoneConfirmOTP(
  Id nvarchar(150) NOT NULL primary key,
  Phone nvarchar(150) NOT NULL,
  OTP varchar(6) NOT NULL,
  Flag bit NOT NULL,
  RequestDate datetime NOT NULL,
  ExpireDate datetime NOT NULL,
)

CodePudding user response:

There is no way to pass your own OTP value to Firebase's phone number verification methods. If you want to use your own OTP value, you will also have to use your own transport to send it to the user.

  • Related