To use the token you need first to sign in to Firebase. The Sign In
component does this for you and use the token internally.
If you want to do it yourself then you need to setup Web API
with the following:
- Header should have
Content-Type
set toapplication/json
- URL should be
https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=
and add your Firebase API Key to it. - Use
Web API POST
block to get the information
See this as an example
Of course instead of displaying the response to a label you will get the token from the response and use it with other blocks.
The response will have lots of information including localId, idToken, refreshToken, expiresIn
Use the localId
in place of the UserID in the Sign In
block and use the idToken
to add it to the URL to get info. So the previous URL which gets information from the database will now be:
https://my-demodb-9d875-default-rtdb.firebaseio.com/myBook/Students.json?token=[your token]
Google will keep this token valid for 3600 seconds and when expires you will need the refreshToken
to issue another API to get extra time with new values.
Hope this will give you a good start.