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

355
Visualizações
Firebase user is logged out on page reload | FirebaseAuthError: Decoding Firebase ID token failed

I am currently using firebase for auth in my web application and one particular issue that I have been facing is that even though the user did not sign out from the application if I reload the page and try to access the current user's accessToken using the following snippet of onAuthStateChanged

import { getAuth, onAuthStateChanged } from "firebase/auth";

const auth = getAuth();
onAuthStateChanged(auth, (user) => {
  const userAccessToken = user?.accesstoken;
   
  doStuff(userAccessToken); // some placeholder function which takes the `userAccessToken` as one of the parameters
});

The user object is null thus indicating the user is signed out. How do I prevent this from happening? Is there a way to ensure that the user stays signed in unless he explicitly signs out from the application?

The onAuthStateChanged must always return the user as not null unless he signs out. The page reloads or any other kind of navigation or operations must not affect this state.

This has particularly been a problem since I require the jwt token of the currently signed-in user to carry out authorization tasks in the backend. The firebase-admin function

const decodedToken = await admin.auth().verifyIdToken(authJwtToken);

upon receiving null errors out

FirebaseAuthError: Decoding Firebase ID token failed. Make sure you passed the entire string JWT which represents an ID token.

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