如何使用php/laravel后端从API验证firebase otp



我有一个使用firebase发送opt的flutter应用程序。问题是,当我从flutter应用程序发送OTP时,没有办法将OTP存储在后端数据库中进行确认。

您可以使用下面的函数

直接从firebase验证otp
await _firebaseAuth!.verifyPhoneNumber(
phoneNumber: "+91${widget.phoneNumber}",
timeout: const Duration(seconds: 60),
verificationCompleted: verificationCompleted,
codeSent: codeSent,);

final PhoneVerificationCompleted verificationCompleted =
(AuthCredential phoneAuthCredential) {
Utility.showLoadingDialog();
print("in phone verification");
_firebaseAuth!.signInWithCredential(phoneAuthCredential)
.then((value) async {
handleNavigation(value);
}).catchError((error) {
print("in error");
print(error);
Get.back();
// showErrorMessage("Try again in sometime");
});
};
final PhoneCodeSent codeSent =
(String verificationId, int? resendToken) async {
Timer(
const Duration(seconds: 15),
() {
// setState(() {
otpSendTimeOut = true;
// });
});
// Update the UI - wait for the user to enter the SMS code
String smsCode = 'xxxx';
setState(() {
_verificationId = verificationId;
});
utils.Utility().showSuccessMessage("OTP sent successfully");
};

最新更新