When you access Firebase using Thunkable you supply API key and Database URL.
The API key is used to create either an Auth token or a User token or both. however, these tokens are only required if you set the Rules in Firebase to deny anonymous access but if you allow access without any authentication then you can actually use the Web API component to get data from the database.
For Example, I have a test database that I do not use any security in it. See the rules:
So, I allow everyone to read or write to this database. In this case, I can get data just by using the Database URL and add to it the keys I want to retrieve and add to the end .json
Example:
My test database is my-demodb and I want to retrieve the key myBook/Students so the full URL will be
Now, when you have security in place then you will need one of the methods to generate a token to access your data. I might write a more descriptive post about how to access using tokens.
Thank you @muneer ! What I was very much wondering about was how you use those tokens for security, indeed, so would be really interesting to hear you to elaborate on this if you find time & inspiration to do it. So, for example, I’ve been using the basic Thunkable components for user authentication with Firebase and then for setting special permissions, say, a user can edit only a folder associated with her username. But now I started to wonder if I could somehow do this manually so I could have more control over these tokens / understand how they function better.
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.
If you use any of the data viewer/source components in the apps, they are dependent on the Thunkable platform. If you use the UI components (such as buttons, labels) and others in the apps, they are not dependent on the Thunkable platform.