First of all, I am starting with Firebase (web) so please let me know if I have misunderstood Firebase concepts. I need to allow only a function to write to the Firebase database. I have read this post and other examples, that are about how to use databaseAuthVariableOverride to add to Firebase configuration a variable that can be used inside the rule to validate the Firebase function write access, that's ok, but my problem with this approach is that seems that the Firebase function is called after is initialized Firebase before and I need to add this variable inside the Firebase function, and when I a do that (add the variable and initialize Firebase inside the Firebase function) this error appears:
The default Firebase app already exists. This means you called initializeApp() more than once without providing an app name as the second argument. In most cases you only need to call initializeApp() once. But if you do want to initialize multiple apps, pass a second argument to initializeApp() to give each app a unique name.
(Please note that the function is related with the same project)
So, I want to know how to only allow to the Function to write when Firebase is already initialized (please let me know if I misunderstood the Firebase life cycle). I must to say that I can not to add the variable at client side for security reasons, and seems that is from the client that Firebase is initialized for first time.