Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

298
Vistas
Firebase : Not able to link phone number with other AuthProviders javascript

I have implemented emailpassword, google and facebook sign in on my web app. But in previous version phone based signin was also there which I had to remove. So I want the previous users to be linked with other options.

I am trying to link phone number to password based account.

enter image description here

Below code is working and the linking is working perfectly but the problem is I want the user to be signed in with password based account and not the phone number based.

enter image description here Below is the error that I am getting.

signInWithCredential failed: First argument "credential" must be a valid credential.'

async function codeVerification(verificationId, verificationCode){

  try {
   const credential = firebase.auth.PhoneAuthProvider.credential(verificationId, verificationCode)

   const prevUser = auth.currentUser;

   // prevUser.linkWithCredential(credential);

   auth.signInWithCredential(credential)
   .then(user => {
    const secondUser = user.credential;
    auth.currentUser.delete()
    .then(() => {
      return prevUser.linkWithCredential(credential);
    })
    .then(() => {
      console.log(secondUser);
      auth.signInWithCredential(secondUser);
      //this is the step where I am getting error I guess, because I am signing in with phonenumber but how to store current credentials of user

    })
  });


 } catch (error) {

 }
}

I want the user to be signin with the password based account only not with the phone number. How can I implement this correctly?

Thanks

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda