nhorvath / Pyrebase4

A simple python wrapper for the Firebase API. ⛺

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Push with rtdb rules

marcelomanzo opened this issue · comments

Please note that I am not using the service account.

I am using the following rules to my rtdb:
{
"rules": {
"users": {
"$user_id": {
".write": "$user_id === auth.uid",
".read": "$user_id === auth.uid"
}
}
}
}

And using the following code:
firebase = pyrebase.initialize_app(config)
auth = firebase.auth()
user = auth.sign_in_with_email_and_password('peter@gmail.com', '*******')

Get a reference to the database service

db = firebase.database()

data to save

data = {
"name": "Mortimer 'Morty' Smith"
}

Pass the user's idToken to the push method

results = db.child("users").child(user['localId']).push(data, user['idToken'])

I can write to the db, but it creates an additional node with the token:
image

Is it possible to write to the db without the token?

Nevermind, using set instead of push works.