Firebase/cloud variable question

Using the cloud variables is awesome to interact with firebase. BUT we cant do PATCH requests. I cant easily modify 1 property of 1 object that I have saved. it would make sense to just use the API request then to accomplish what the cloud variable doesnt. BUT my DB has rules ground down to the user bucket meaning each user can only modify their own bucket.

this again is fine for most use cases but not PATCH. When patching my url needs to look something like this

https://docs-examples.firebaseio.com/rest/saving-data/users/alanisawesome.json?auth=<idToken>

at first, i thought this was the user id but it isnt. it is the token provided by firebase upon login which changes every time a user logs in or after some period of time.

This means you cant use both together because you have to sign in and get the token at the sign of login.

is there any way we can get another block to not only get the userID but also the token.

otherwise i plan to use the API for everything in my app and that makes me cry a little. (not really) it’ll just be more work

an API response example

    {
    "kind": "identitytoolkit#VerifyPasswordResponse",
    "localId": <THIS IS THE VALUE RETURNED FROM THE GREEN userID FIREBASE BLOCK,
    "email": "jared.gibb@gmail.com",
    "displayName": "",
    "idToken": "eyJhbGciOiJSUzI1NiIsImtpZCI6InRCME0yQSJ9.eyJpc3MiOiJodHRwczovL2lkZW50aXR5dG9vbGtpdC5nb29nbGUuY29tLyIsImF1ZCI6ImxvZ2luLWRhdGFiYXNlLWJyYyIsImlhdCI6MTYwODMyNzM1MiwiZXhwIjoxNjA5NTM2OTUyLCJ1c2VyX2lkIjoiNGpWMzlhRUs2ak9lY0xkS09OSk1LYXRzRVluMSIsImVtYWlsIjoiamFyZWQuZ2liYkBnbWFpbC5jb20iLCJzaWduX2luX3Byb3ZpZGVyIjoicGFzc3dvcmQiLCJ2ZXJpZmllZCI6dHJ1ZX0.sO9_pyf5-4byfIPC633GrabVjr81HNd2qoxy1kdpAY9yx9MbMtmcTVWYr3MFmUg68zkAqOux9Zsmy_o270Wb3cVpP8DDRbmJnscV7pua0J-0AOfF7F3tPEc3wdNeopMF7uCfrBBk5NCE4hOM0jucG6NvQnjNIiMU7PKQC7aGe0XCYBE9eI5zsMW6kfPZuXFdCKXLzdxETxm8i6uT38yotf3BnQ03XezgKCOjmcS0HX8-nhSKClpo4pTygfroP6NDFuQhRuETxPkd5fW6qYwPXwja8TARg3-3CG3NQz0yGE9lW_2gP2Zbo1B5oYZwEsE4sFgBZodphz81vn88gQirzA",
    "registered": true
}
1 Like

You can though. You can directly reference any firebase property using a cloud variable text string.

What is an example of a firebase path to the property you want to update?

1 Like

I want the current bucket that looks like this

{
Name: “Jared”
Notes: “silly guy”
}

To look like this

{
Name: “Jared”
}

Url:

https://docs-examples.firebaseio.com/BRC/<userID>/data/1.json?auth=<idToken>

API body:
{“notes”:null}
1 Like

Check out this topic.

2 Likes

I never realized I could go down to the single property! I will post solution blocks soon!

3 Likes

The link @drted posted should give you enough to do some trial and error testing with blocks.

My guess for your bucket – I’m not the best at deciphering JSON and I tend to use a JSON converter to view it easier but I can’t quite do that with what you posted – is this:

(Thunkable isn’t loading for me so I can’t share a screenshot… bear with me…)

Set cloud [bucket_name/top_level property*]/…/Notes to “”
Set cloud [bucket_name/top_level property*]/…/Url to "https://docs-examples.firebaseio.com/BRC//data/1.json?auth=
Set cloud [bucket_name/top_level property*]/…/API body/notes to “”

Everything after the word “cloud” would be inside a text box. You have to use the Set cloud block that already has a text block attached.

There might be another way to remove the “Notes” property – I’m not sure.

*Sorry, I’m very new to firebase so I may have the lingo a bit off!

1 Like

You got it. I tried that earlier and it works. I’ll post blocks tomorrow morning!

2 Likes