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

how to refresh firebase token from back-end using node.js

I need to know that if that possible to refresh the firebase access token from back-end using node.js. I can get the token from front end and I need to refresh it and verify if the token is expired.

condition : if the token expired then need to refresh it in the back-end. but the token is generating from front end.

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 :

You need the Refresh Token to get a new ID Token (Access Token). If you are using the Firebase Auth Client SDK, then it’ll do all of this.

// This returns existing token if valid 
// else it'll refresh the token and return an new one
const token = await auth.currentUser.getIdToken()

In case you still need to get new token in your backend server, then you can use Firebase Auth REST API.

Again, you’ll need to store the refresh token in a secure place and I won’t recommend doing this unless it’s just for testing or you don’t have any other way.

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