I’m using firebase authentication using phone number. I have added my number for testing which works fine and even I can see captcha verifier for same. But if I try with another phone number I’m getting error below
[firebase_auth/invalid-app-credential] The phone verification request contains an invalid application verifier. The reCAPTCHA token response is either invalid or expired.
Code:
Future<ConfirmationResult> authViaPhoneNo({
required String phoneNo,
}) async {
return auth.signInWithPhoneNumber(phoneNo);
}
Future<User?> verifyOTP({
required ConfirmationResult result,
required String otp,
}) async {
final credential = await result.confirm(otp);
return credential.user;
}
}
Also If i use with captacha
final captchaVerifier = RecaptchaVerifier(
container: 'recaptcha',
size: RecaptchaVerifierSize.compact,
theme: RecaptchaVerifierTheme.dark,
auth: FirebaseAuthPlatform.instance,
);
I’m getting this error
DartError: Assertion failed: file:///Users/user-name/.pub-cache/hosted/pub.dev/firebase_auth_web-5.12.0/lib/src/firebase_auth_web_recaptcha_verifier_factory.dart:94:9
web.window.document.getElementById(container) != null
"An exception was thrown whilst creating a RecaptchaVerifier instance. No DOM element with an ID of recaptcha could be found."
4
You may need to add reCAPTCHA configuration for your sign in method as mentioned in the documentation Phone Authentication
1