Answer the question
In order to leave comments, you need to log in
Firebase - how to get user data by reading a token from LocalStorage?
There is a token in LocalStorage
const token = await firebase.auth().currentUser.getIdToken()
localStorage.setItem('token', token)
Answer the question
In order to leave comments, you need to log in
Here is what I found for your question
so when you get a token you need to remember the time and check if its time has expired the next time you use it.
And here I found more material on how to get user data
https://firebase.google.com/docs/auth/web/manage-users
var user = firebase.auth().currentUser;
var name, email, photoUrl, uid, emailVerified;
if (user != null) {
name = user.displayName;
email = user.email;
photoUrl = user.photoURL;
emailVerified = user.emailVerified;
uid = user.uid; // The user's ID, unique to the Firebase project. Do NOT use
// this value to authenticate with your backend server, if
// you have one. Use User.getToken() instead.
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question