I'm facing an issue in my MobX store where I can't retrieve the accessToken from Firebase login, even though the data is present. This pertains to a React-Native environment.
Example:
class GlobalStore {
@observable loggedIn: boolean;
@observable user: any;
@action firebaseStatup = () => {
firebase.initializeApp({
apiKey: "somestring",
authDomain: "app.firebaseapp.com",
databaseURL: "https://app.firebaseio.com",
projectId: "app",
storageBucket: "app.appspot.com",
messagingSenderId: "1234
});
firebase.auth().onAuthStateChanged((user) => {
this.loggedIn = !!user;
if (user) {
this.user = firebase.auth().currentUser;
console.log(this.user); // Displays an Object containing stsTokenManager.accessToken which is the JWT?
console.log(this.user.stsTokenManager.accessToken)
}
})
};
console.log(this.user);
shows a detailed user object with all information. However, trying to access stsTokenManager.accessToken
directly throws an error:
undefined is not an object (evaluating '_this.user.stsTokenManager.accessToken')
How can I successfully retrieve the accessToken
that is clearly available?