JordanDavis
JordanDavis

Reputation: 71

Firebase Auth throwing "auth/internal-error" when trying to use PhoneAuthProvider method in Ionic React IOS mobile application

I am currently having some issues trying to integrate Google Firebase authentication into a React Ionic mobile application. So far I have been able to set up the app to run correctly on both web and android but am running into repeated issues with IOS. The code runs correctly for Firebase auth login on android does not seem to be running on IOS.

The initial call to "signInWithEmailAndPassword" seems to work fine and returns "auth/multi-factor-auth-required" but any time I try to make a call to "verifyPhoneNumber" on ios I will receive the response of "Firebase: An internal AuthError has occurred. (auth/internal-error)", there are no further details provided in any part of the error returned.

//Firebase setup in seperate file with code like these 2 lines 
app.initializeApp(config);
const firebaseAuth = app.auth();
//

firebaseAuth
.signInWithEmailAndPassword(email, password)
.then(function (user) {
        //other code
})
.catch(function (error) {
        if (error.code === "auth/multi-factor-auth-required") {
            let resolver = error.resolver;
            setTimeout(() => {
                phoneAuth(appVerifier, resolver);
            }, 2000);
      } else {
          //other code
      }
});

//following code is part of the method phoneAuth() above
var phoneInfoOptions = {
    var phoneInfoOptions = {
      multiFactorHint: resolver.hints[0],
      session: resolver.session,
    };
    var phoneAuthProvider = new firebase.PhoneAuthProvider();
    phoneAuthProvider
      .verifyPhoneNumber(phoneInfoOptions, appVerifier)
      .then(function (verificationId) {
        console.log("verify Id recieved");
      })
      .catch((error) => {
        console.log(error);
      });

Things I have checked/tried so far are: followed all steps in firebase docs Setup ios app in firebase console and followed the steps listed

Has anyone run into issues like this previously and has any advice on what I could check next?

Thanks

Upvotes: 7

Views: 1762

Answers (1)

Galen Howlett
Galen Howlett

Reputation: 675

The phone sign in fails on ios due to the recaptcha requiring a non-existent http/s schema. The best solution right now seems to be the unofficial capacitor firebase auth plugin: https://capawesome.io/plugins/firebase/authentication/

Upvotes: 0

Related Questions