How to refresh firebase token correctly?

I’m using mirxtrem extension to login/signup to firebase.
idToken is valid for temporary time so i need to use refreshToken block to renew it but when im trying to get new token it i see nothing (into label text)
note that login/signup is in screen2

1 Like

Why you want to refresh the token. Make after an hour a new sign in.
the Token should changed each hour.
To if your token get changed make a new sign in and get a new token with that.
This shoudl work also.

I want to make tests to see if it works to me
why to sign in every time if I can replace the token, I want to learn how to change it correctly.
do you have suggestion how my blocks should be? bcz i couldnt make it work properly

Hello! I have this same inconvenience because I need to make some changes in the firebase database and as is well known, due to the writing rules I need to send and check the tokenID before writing.

did you do anything about it?

I can only think of requesting a new tokenID after 60 minutes, it’s that easy, I think it’s easy, I just try to find out if someone has already done so and share ideas.

Hi
Im using sign in every time I enter the app to make sure that i get new token every time
replay me if you want to see blocks

1 Like

At first I thought about requesting the token every time the app was started but I don’t want to saturate the app anymore, I tried to do two tests with the expireIn variable but I was not successful in converting the unix time, I will do more with the unix time.

1 Like

Hi @yoni_mic , after doing some tests I am not sure that the refreshToken block works, it is not generating the token every 3600 sec. I made the request.

Could you show your blocks please, maybe he’s doing something wrong.

well you are using ‘mirxtrem’ extension Im not using it any more and ‘refreshToken’ didnt worked for me either, Im doing regular sign in every time I enter to the app (not the most effective way but its working). by the way if you are using timer and you set it to run every 1 hour then it will not be accurate enough it has some very bad lags if milliseconds are too high.
here are my blocks for getting new token:

I get it! I imagined that this is the solution, although it is definitely not the right one!

I’m using the mirxtrem extension and I can’t make RefreshToken work.

I’ll keep looking, thanks!

By the way, the way I perform the check is that when the user logs in, I keep the exact date of when that happens and every time the application starts I check how much time has elapsed, if it is longer than 60 minutes then I request a new token and again I keep the exact date.

The date does change after the condition is met, but the token does not.

great! I need to improve the logic of pulling the token like you did when I will have the time

After seeing some examples I have succeeded, get a new token. It is really easy and the important thing is that you can do some more things just by changing some blocks such as: reset password, login, etc. etc.

Later I will post the blocks and the link of the web on which I am based, I am sure that more than one will serve this REST API.

With these blocks I managed to get a new id token every 3600 seconds, for firebase authentication.

In my case I need to write data in firebase, but the write permission is only available for authenticated users, so I need to renew the token every time it expires.

3

I think this is better than being logged in every time the user runs the application.

Modifying this example, we can create new users, log in or even reset the password, we can stop relying on one more extension in our application in my case Firebase Auth v3 that although it helped me to build my project, it stopped being To some extent, Google Play Console sent me an alert of API data exposed in my app, because Firebase Auth v3 does not allow obfuscating the API key.

More examples to use. Firebase Auth REST API  |  Firebase

1 Like

I moved the new post into here…
I think it makes more sense to provide the answer to the question here…
Taifun

1 Like