1
votes

I am trying to delete a node from firebase database using rest api. I can read the database, but when i try to delete or write to it , it gives me permission denied error. I am using python requests package to make rest calls. here are my security rules for firebase database

{  
"rules": {

".read": "auth.uid == 'foobar'",
".write":"auth.uid == 'foobar'"          
}
}

I have a user in firebase console -> authentication -> users with user uid as "foobar". Here is the python code to make delete request

url='https://www.googleapis.com/identitytoolkit/v3/relyingparty/verifyPassword?key=<my-api-key>'
data={
"email": "my-email",
"password": "my-pass",
"returnSecureToken": "true"
}
contents = requests.post(url,data)    
idToken= contents.json()["idToken"]
payload = {"auth":idToken}
#i also tried sending uid with payload
#payload={"auth":idToken,"uid":"foobar"}
url="https://my_app_id.firebaseio.com/Home01/.json";
contents=requests.delete(url,data=payload)

how can i make delete request successfully.

1

1 Answers

1
votes

I believe auth should be sent as a query parameter, as opposed to it being a part of the request body. Chances are Firebase REST API is ignoring the body of the DELETE request. Try using params=payload instead of data=payload in the call to requests.delete().