# Firebase/cloud variable question

**URL:** https://community.thunkable.com/t/firebase-cloud-variable-question/1040000
**Category:** Questions about Thunkable X
**Created:** [December 18, 2020, 10:27pm UTC](https://community.thunkable.com/t/firebase-cloud-variable-question/1040000 "2020-12-18T22:27:58Z")
**Posts on this page:** 8
**Page:** 1

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [December 18, 2020, 10:27pm UTC](https://community.thunkable.com/t/firebase-cloud-variable-question/1040000/1 "2020-12-18T22:27:58Z")

</div>

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

```auto
    {
    "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
}
```

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [December 18, 2020, 10:42pm UTC](https://community.thunkable.com/t/firebase-cloud-variable-question/1040000/2 "2020-12-18T22:42:39Z")

</div>

> [@jared](#):
>
> BUT we cant do PATCH requests.

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?

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [December 18, 2020, 10:48pm UTC](https://community.thunkable.com/t/firebase-cloud-variable-question/1040000/3 "2020-12-18T22:48:48Z")

</div>

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}

```

---

<div class="post-metadata">

### Author: ![drted](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/drted/32/92694_2.png) [@drted](https://community.thunkable.com/u/drted)
#### Post date: [December 18, 2020, 11:05pm UTC](https://community.thunkable.com/t/firebase-cloud-variable-question/1040000/4 "2020-12-18T23:05:55Z")

</div>

Check out this topic.

> [@Replace GET or SAVE Blocks with cloud variables](http://community.thunkable.com/t/thunkable-hack-deep-firebase-json-data-manipulation-without-using-get-or-save-blocks/975738):
>
> I just discovered a VERY simple and fast way to get and set Firebase data without using the GET or SAVE blocks (which has all sorts of asynchronous issues). The 2 any button click blocks below return the same data. Just put the GET block KEY variable into the CLOUD variable name and PRESTO. You have a synchronous call to firebase! Similarly, you can set data anywhere in the JSON Hierarchy using cloud variables. Both of the examples below update Firebase, but the CLOUD based solution…

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [December 19, 2020, 12:34am UTC](https://community.thunkable.com/t/firebase-cloud-variable-question/1040000/5 "2020-12-19T00:34:06Z")

</div>

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

---

<div class="post-metadata">

### Author: ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)
#### Post date: [December 19, 2020, 5:01am UTC](https://community.thunkable.com/t/firebase-cloud-variable-question/1040000/6 "2020-12-19T05:01:02Z")

</div>

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/](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!

---

<div class="post-metadata">

### Author: ![jared](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/jared/32/138473_2.png) [@jared](https://community.thunkable.com/u/jared)
#### Post date: [December 19, 2020, 5:10am UTC](https://community.thunkable.com/t/firebase-cloud-variable-question/1040000/7 "2020-12-19T05:10:44Z")

</div>

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

---

<div class="post-metadata">

### Author: ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)
#### Post date: [November 8, 2024, 12:19pm UTC](https://community.thunkable.com/t/firebase-cloud-variable-question/1040000/8 "2024-11-08T12:19:40Z")

</div>


