Firebase Authentication issue

@Hassan_Alzaki What are your firebase rules? Can you show us a screenshot of your rules tree?

My rules are private to my DB structure.

I tested it with theses rules below and it works!

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

Try with a new project and let me know the result.

1 Like

I access different buckets from the same database from different pages on my app. I also use the when data changed block. Do you know if this method might work in this case?

This is exactly what I do. It works fine. Follow my steps above and report the result.

Do I need to update the token on each screen?

but how do a new user write in database?

No, once the user signed-in and you updated the token in Screen1 for instant, no need to update in Screen2.

Follow my posts above.

In summary:

  1. Set the right rules according to your DB structure. Reference
  2. User sign-in.
  3. Authentication success.
  4. Update the token.
  5. Set your project bucket.

Don’t forget

Does that error block need to go on each screen I’m accessing FB from?

I use it only in Screen1, where the users sign-in. I leave it empty in order to not bother the users with (permission denied) error which appear before the sign-in Auth.

1 Like

Huzzah! It Works! @storkgdev, @gopayarg, I got it to work with “auth.uid != null” following this method.

3 Likes

Glad to hear it works :heart_eyes:

1 Like

Great!! I will give it a go!

Nice! Thank you guys!

Did you try it with the following:

“.read”: “auth.id == $uid”,
“.write”: “auth.id == $uid”,

Did it work?

I didn’t test that one. I’m not tracking users the way most people are though. most of my “users” are logged in under a single G Suites email that my company uses for all of our technician tablets (they don’t all need individual emails). So my rules are very basic.

Yes, as long as you set up everything correctly.

It worked with auth != null, but with auth.uid == $uid, it doesn’t work.
Shows error as before :confused:

1 Like

Show me your FirebaseDB structure and rules

Here I’m attaching my firebase_rules.json and firebase_db.json file as a zip.
firebase.zip (975 Bytes)