Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

288
Views
Firebase signInWithCredential does not throw error with wrong credential

I am using React Native with Expo. I'm trying to create phone authentication for my app using Firebase and the following function should throw an error according to the signInWithCredential documentation if you put a wrong verificationCode. However the function just logs a null user value and throws no error.

const confirmPhoneVCode = async () => {
try {
  const credential = PhoneAuthProvider.credential(
    verificationId,
    verificationCode
  );
  // Sets the user variable
  await setUser(signInWithCredential(auth, credential).user);
  console.log(user);
  console.log("phone auth worked with user");
} catch (err) {
  console.log(err);
}};

I use the following code to send the verificationCode:

  const sendPhoneVCode = async () => {
// The FirebaseRecaptchaVerifierModal ref implements the
// FirebaseAuthApplicationVerifier interface and can be
// passed directly to `verifyPhoneNumber`.
try {
  const phoneProvider = new PhoneAuthProvider(auth);
  const verificationId = await phoneProvider.verifyPhoneNumber(
    phoneNumber,
    recaptchaVerifier.current
  );
  setVerificationId(verificationId);
  console.log("Send to phone");
} catch (err) {
  console.log(err);
}};

If you input the right verificationCode the function still logs a null user value but then this function sets the right user value afterwards

auth.onAuthStateChanged((foundUser) => {
if (foundUser) {
  setUser(foundUser);
  console.log("Found user and set it");
}});

Can someone see what my error is?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!