Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

144
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda