Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

352
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!