FirebaseDB : Error from Companion

I encountered this issue "Error from Companion: For a custom firebase host you must first set your authentication server before using authentication features!" and still can't solve it. Does anyone have experience or suggestions to help?

  1. I am a complete beginner.
  2. I am not good at coding, just starting to learn.
  3. I am not good at English (Haha).

Several things you can try:

  • In the Firebase console, you need to, as a minumum, visit the Authentication section of your project. You may also need to setup email/password as a sign in method.
  • Note that the AI2 Firebase component will only work with project on the us-central server.
  • Note that the AI2 Firebase component does not work if you use Firebase Authentication.

You might consider this approach instead (note that there are also a couple of free extensions that also provide access)

1 Like

Thank you very much, Master. Your advice is better than Chat AI. I have noticed one issue:
"Note that the AI2 Firebase component will only work with a project on the us-central server." I am using (asia-southeast1), but it is strange that data is being saved to Firebase Real-Time Database. However, it always shows the message "Error from Companion: For a custom firebase host you must first set your authentication server before using authentication features!" on the website.

Additionally, there is another point: "Note that the AI2 Firebase component does not work if you use Firebase Authentication." I don't fully understand this — does it mean using email login as well? I’m not very good at English, so I might not fully understand. Thank you very much. I will try to fix it. Please continue to advise me when I encounter more issues.

Did you visit the Authentication page ? (to get rid of that error)

Have you set any secure rules ?

If you use Firebase Authentication as you signup/signin process, sending/receiving data using the Firebase component will not work, because it does not recognise the secure rules in place.

I should have been more specific, if you set secure rules in your firebase project, to tie in with the use of firebase authentication, the firebase component will not work.

I guess you could just use Firebase Authentication for user authentication and management, and then keep your data read and write: true

1 Like

data read and write: true = Yes
"But I somewhat understand that if it's not True, it won't work, right?
Do you happen to have a solution?
The link you provided is interesting, and it's in my country's language too. But I want to try using the Authenticator email extension because it seems easier to me. :sweat_smile::sweat_smile:"

"If I were to set it up like this:

{
"rules": {
"users": {
"$user_id": {
".read": "auth != null && auth.uid === $user_id",
".write": "auth != null && auth.uid === $user_id"
}
}
}
}

Do you think it will work? I’m guessing it won’t. :sweat_smile::sweat_smile:"

Not if you use the AI2 Firebase component

1 Like

"Can you give me some advice? I don’t know where to start."

Start by telling us exactly what it is you are trying to achieve with your AI2 project.

1 Like


"This is what my block looks like.

I want to fetch data from a specific UID and store data in that UID, while ensuring that anyone who has the Firebase URL cannot modify the data.

(I’m not sure if I’m communicating this correctly. I apologize in advance, and thank you for your advice, teacher.)"

Well, that will not work, you need more (a different extension or the web component)

You could try this:

or this

For both, ensure you use and understand secure rules.

1 Like

(post deleted by author)

You need to insert "users" to your pathData variable, because that is how you have your rules set...

image

should read:

users/get localId

(You may need a / at either the start or end, or both, check the documentation for the extension

1 Like

"I have made the changes, but saving still doesn't work; I can only sign up. (I'm not sure if email verification is required first.)"
"The ResponseCode I received when performing PutIn is 404."

No it is not required

You should also use the extension blocks to PUT and PATCH data

1 Like

"Please check my block setup. The result still doesn't save the data."

This

image

will always set Label1 to error

You do not need these blocks

Check the values from the SignIn event, are you getting an idToken (should be a very long string of characters), and a localId token (a shorter string of characters)

1 Like

"I have obtained both the UID and ID token. I am quite confident that the values returned are correct."

I ran a test on my system using the extension, it works well...

BLOCKS

SECURE RULES (as for shoppingList in the extension documentation)

     "users": {
        "$uid": {
           ".read": "auth.uid == $uid" ,
           ".write": "auth.uid == $uid"
        }
     },

Firebase Data (written)
image

Notes

Example firebase url = https://myfirstdb.firebaseio.com/

Example projectId = myfirstdb

APIKey is found on the Project Settings page

1 Like