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.
CodePudding user response:
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.