Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there a way to manually trigger onAuthStateChanged in firebase auth?

I tried several ways, like:

auth.currentUser.reload();
auth.currentUser.getIdToken(true);

but none of them works, the onAuthStateChanged listener is not getting called. Its very important for me. Thanks.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The onAuthStateChanged event is triggered by the SDK when the user’s auth state change, so when it goes from not being signed in to being signed in – or vice versa.

If you want to detect when their ID token changes, you’ll want to listen for onIdTokenChanged instead.

There is no way to trigger these event from your own code, although you can of course execute the same code yourself whenever you have another need.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading