Permission Denied Error in Firebase Database with Locked Mode

I’m working on a project using Firebase Authentication and Realtime Database in Kodular. I’m trying to save the user’s email after Google Sign-In. The data saves successfully in Test Mode, but I get a “permission denied” error in Locked Mode.

My Setup:

  • I’m using Firebase Authentication for Google Sign-In.
  • After Sign-In, I’m saving the user’s email in the Realtime Database under the path /Users/<sanitized-email>.
  • I’ve attached a screenshot of my blocks below (it includes the Google Sign-In and StoreValue logic).

Rules I Tried:

  • Test Mode (worked):
    { “rules”: { “.read”: true, “.write”: true } }
  • Locked Mode (not working):
    { “rules”: { “.read”: “auth != null”, “.write”: “auth != null” } }

Error: I get a “permission denied” error in Locked Mode, but data saves fine in Test Mode. In the Firebase Console, the Authentication tab shows the user’s Gmail, so Sign-In is working.

Steps I Tried:

  • Refreshed the authentication token (deleted users, signed out, and signed in again).
  • Reset configurations (re-uploaded google-services.json, re-added Firebase components, verified Firebase URL).
  • Tried different rules, but nothing worked.

Please suggest a solution!