Firebase: Error (auth/argument-error).
FirebaseError: Firebase: Error (auth/argument-error).
import { getAuth, RecaptchaVerifier, signInWithPhoneNumber } from 'firebase/auth';
import { firebaseConfig } from '../Global/firebaseConfig';
import { initializeApp } from 'firebase/app';
const setupRecaptcha = () => {
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
auth.settings.appVerificationDisabledForTesting = true;
// @ts-ignore
window.recaptchaVerifier = new RecaptchaVerifier('recaptcha-container', {
'size': 'invisible',
'callback': (response: any) => {
// reCAPTCHA solved
}
}, auth);
};
const sendVerificationCode = () => {
const app = initializeApp(firebaseConfig);
const auth = getAuth(app);
auth.settings.appVerificationDisabledForTesting = true;
// @ts-ignore
const appVerifier = window?.recaptchaVerifier;
signInWithPhoneNumber(auth, sendTo, appVerifier)
.then((confirmationResult) => {
setConfirmationResult(confirmationResult);
}).catch((error) => {
setError("Error sending SMS: " + error.message);
});
};
const verifyOtpSubmit = async () => {
if (confirmationResult) {
confirmationResult.confirm(otp)
.then((result: any) => {
const user = result.user;
setVerified(true);
}).catch((error: any) => {
setError("Error verifying code: " + error.message);
});
}
};
<div id="recaptcha-container"></div>
"firebase": "^9.23.0",
I tried changing versions but nothing is working. but i keep getting same error, through console.log i can see that issue is with recaptchaVerifier