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

168
Visualizações
Verify ID Token provided by Google with Firebase in Expo

i recently allowed users to sign-in in my Expo app with Google 0Auth2.0.

The problem is that when i need to verify the token provided in my backend, i have a 400 error.

(only with Token provided by Google not with a token that i get from basic email/password authentification)

  • In my client :
export async function getUser(id){
    console.log("Reading user... ")         
    try{
        const token = await auth.currentUser.getIdToken()
        const response = await axios.get(`${root}/users/get_currentuser/${id}?auth=${token}`)
        return response.data
    }
    catch(err){
        console.log(err.message)
    }
}
  • In my backend :
const get_currentuser = async (req, res) => {

    const id = req.params.id
    const auth = req.query.auth
    try {
        const result = await getAuth().verifyIdToken(auth) // the error is here 
    
        if(result.uid === id){
            try {
                const user = await db.collection("Users").findOne({uid : id})
                res.status(200).json(user)


            } catch (error) {
                res.status(500).json(error)
            }
        }
        else
            res.status(400).json({err : "Connexion impossible"})

    } catch (error) {
        res.status(400).json({err : "Connexion impossible / token error "})
    }
    
}

Thanks in advance for any help !

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Okey ! I found the solution.

I just remember that my Firebase-Admin-SDK wasn't correct because i created a new Firebase project, so i used the wrong Private Key ( the key that we generate in Profil Setting )

So to fix the issue i generated a new Private Key and that helped me.

about 4 years ago · Juan Pablo Isaza Relatório
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