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

147
Vistas
How to use SignInWithRedirect with GoogleAuthProvider?

I am creating a Vue App (Vue version 2). I am using Firebase (Web version 9) as a database and for the authentication. I am using Google as Sign in method. On desktop I want to use the signInWithPopup method, which works perfectly fine. However they recommend using signInWithRedirect on mobile. I do not understand how this second method have to be used. Here is what I have done so far :

googleSignIn: async function () {
    const auth = getAuth();
    const provider = new GoogleAuthProvider();
    try {
        let result;
        if (this.isMobile) {
            await signInWithRedirect(auth, provider);
            result = await getRedirectResult(auth);
            if (result) {
                console.log(result);
            } else {
                console.log("no result");
            }
        } else {
            result = await signInWithPopup(auth, provider);
        }
        const googleUser = result.user;
        const query = await db
           .collection("users")
           .where("email", "==", googleUser.email)
           .get();
        if (!query.empty) {
           this.$store.dispatch("setUser", googleUser.reloadUserInfo);
            this.$router.push({ path: "/dashboard" });
        } else {
            alert("impossible de se connecter");
        }
    } catch (err) {
        console.log(err);
    }
}

Here are my imports :

import { getAuth, signInWithPopup, signInWithRedirect, getRedirectResult, GoogleAuthProvider, } from "firebase/auth";
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