Firebase Authentication error

these are my rules for firebase database
{
“rules”: {
“.read”: “auth != null”,
“.write”: “auth != null”
}
}

but while my user sign with google , it shows firebase error, and dosent load any data

Hi @me_onlinebusiness welcome to kodular community.
Showing some blocks helps us to help you.

i have the same issue, i am able to login with google but not able to store data to Firebase
see my block

Is it showing any error?

error message

Firebase Auth doesn’t work in the Companion

Firebase rule:
// Only authenticated users can access/write data

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

// Checks auth uid equals database node uid
// In other words, the User can only access their own data

{
“rules”: {
“posts”: {
“$uid”: {
“.read”: “$uid === auth.uid”,
“.write”: “$uid === auth.uid”
}
}
}
}

i tried both one by one got the same error

Firebase authentication don’t work in companion you have to export apk

1 Like

As error tells you Firebase Auth does not work in Companion.
And to use rules in Firebase read this:
https://docs.kodular.io/guides/component-examples/securing-app/#overview

Exported app now i getting FirebaseError Permission denied

Set Firebase rules to test mode.
i.e.

{
“rules”: {
“.read”: true,
“.write”: true
}
}

1 Like

in test mode it store value but i only want Authorized User to read-writhe data

Any Solution? I’m running into the same issue. My users authenticate just fine, but I get a permission denied error if I’m not in test mode. Even “auth != null” doesn’t work.

+1

My app works pretty fine when I compile the apk, install and run on my device but as soon as I publish it to PlayStore it runs into FireBase Login failure. I’m using the Google Sign In option for Login! Please respond if someone can help. TIA! :slight_smile:

Try the solution in this thread

2 Likes

As I said earlier

But,

I mean to say when I download my app from Playstore and after Google SignIn my app runs into Login_Failed() everytime!
I tried flushing my entire database to null but there isn’t any difference. :pensive:

I am attaching my blocks below:

One thing I’m seeing that seems to be missing is setting the Firebase Token. Not setting the token after login will get you a login error. I got them constantly without setting read/write to true until I learned that. Give it a shot. Check out the topic I linked and it should all be explained there.

1 Like

I’ve set the Firebase Token in the Designer part itself and also my Firebase Rules are in Test Mode i.e., both read/write are set to true. Is there any way to retrieve the login error message as we can get that in SignUp_Failed()??

Firebase Token is usually different in every session. Setting it in the designer is not the best practice.

1 Like

Correct me if I’m wrong. But we need to set this Web API Key as Firebase Token for all the Firebase instances right? So why would it change in every session? Also if that be the issue then the app won’t have worked when compiled. The app is going under Login Failed only when published to the play store.

The firebase token should match the ID token from the authenticator. The ID token changes when you use the authenticator to log in. The ID token resets hourly (I believe), so you have to pull the ID token on firebase error with the authenticator and update the firebase token with it to keep from getting those errors. Once I took these steps I never saw that error again and could update my firebase rules instead of leaving read/write permissions to true.

2 Likes

I updated my blocks as per the guide you mentioned above and it is working fine as per now. I’ve applied for an update on the PlayStore and will let you know if everything goes good. Thanks :slight_smile: