I'm trying to update records in Firebase Realtime database using React Native via API.
During development I had Read/Write rules opened to everyone and used to update specific items using the following code
const response = await fetch(
`https://mydatabase.firebaseio.com/myTable/recordID/basic.json`,
{
method: "PATCH",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
field1: newValue1,
field2: newValue2,
field3: newValue3,
}),
}
);
Now I have restricted the "write" rule to a specific user that I have created. Basically only this user (the admin) can write into firebase
".write": "auth.uid === <User UID>"
I've been trying to pass the authenticated user details at the end of the json like this
https://mydatabase.firebaseio.com/myTable/recordID/basic.json?auth.uid === <User UID>
but it doesn't seem to work.
The documentation shows options to add ID Token or Google OAuth2.
Any suggestion would be very much appreciated