[Firebase Auth] idToken expires?

Hello community, Im about to launch my app, everything is going great but i’ve got a problem with firebase token I guess -

My problem was that after a period of time, I’ve received the “Firebase error” and can’t access my db (I’ve got rules that only registered users can access DB) and I set the firebase token with the respective user token, (I save it in the tinydb when the user goes through sign in - but as I also have it to remember the password it goes from screen 1 -> home) - Anyways I need to know how it works. Im just giving a background.

I do not understand how it works, does it automatically refresh? So everytime that the user log in will have a new token ID? In case yes, whats the frequency of the change of token ID???

Please help me to solve this issue!!!

2 Likes

This can be helpful for you i think:
https://docs.kodular.io/guides/component-examples/securing-app/

Yes it is useful but I don’t want to secure my database at that level right now

I just want to know how the Firebase token works.

Does it refresh for each user? Whats the frequency of that?

1 Like

Firebase Token is permanent, you can’t edit or delete Firebase Token.

No, Firebase Token is always same for one project.

1 Like

Then why did it change in 5 minutes?
image

image

This firebase Token is provided by Kodular as hint, you have to remove it from designer part and set your own Firebase Token from block part.

Does that happen every time or sometimes?

Sometimes - For now what I’m doing is a hidden login in screen 1, so I get the latest idToken there (everytime he opens the app), save in the tiny db and use it afterwards to set each database firebase token.

I just want to know what happens if the user stays X time in the app, will he logout/stop being able to write/read my DB at sometime if the id expires and then an error would pop up? I will be testing this by staying in the app a lot of time and see what happens.

I need to know if here
image

goes this

or the idToken received from the user
image

My rules are

{
“rules”: {
“.read”: “auth.uid !== null”,
“.write”: “auth.uid !== null”
}
}

Token id is available in this images. Token id didn’t received from user if they signup. Token id is permanent and unique for every project.

And then why this error pops ups
image

If i don’t set up this as FirebaseToken
image

Moreover this (default token) image looks more like the ID token than the Api Key

Try with this -
Remove this block - Got id Token and set Token id with obfuscated text from block.

Hello @Jfdsb ,
Is your problem solved or not ?

Maybe this will help you, currently it works in my app without any problem, for me it’s a direct way to work with firebase without the need of extensions, just the web component.

https://community.kodular.io/t/how-to-refresh-firebase-token-correctly/25862

I’ve created a new project to understand the firebase auth

image

This works unless I let +60 MINS without open the app

P.S: I’ve also tried this blocks
image

Id tokens expires each hour… the solution is calling a new idtoken and set a new id toker… if you need more help a can show you the block. good luck

Yes please. but am I not doing what your saying? I mean each time the user gets in the Screen 1 (opens the app) Im calling a new token. I checked it because I got into 2 or 3 times and I noticed it changed.

Im trying it right now again and here is the results of open the app twice (two diferent tokens):


If you show me how you’ve done it i would appreciate it a lot! im struggling with this

to get new idtokens use this:

If you are in the same screen for an hour and you want to reset a new idtoker you can do it with a clock to get a new idtoker automaticaly.
You will have the same id token… each hour the idtokens change

I’ve got done that here and still saying “firebase error” when i wait for +60 mins and open it again

can you show your firebase rules?