T
T
talaxasi2021-06-29 13:27:47
JavaScript
talaxasi, 2021-06-29 13:27:47

How to send idToken to firebase backend for validation?

When authorizing a user for a chat, I get an idToken from firebase, but when rendering a new page, I need to check the token I have on the back end. How to implement a request from the client to the firebase backend to get a response about the validity of the token?
The documentation describes the firebase admin library, but it is for the backend.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander K., 2021-07-01
@Kurochen

There is also a Firebase library for the client (it also includes firebase / auth) - doc
Accordingly, you can get the current idToken from it

firebaseApp.auth().currentUser.getIdToken(/* forceRefresh */ true)

where forceRefresh - forced reset of the token to a fresh one. Methods and properties of the library - doc
As far as I understand, the library itself monitors the tokens, if necessary, turned to it.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question