cannot add data to firebase

firebaseProject.aia (55.2 KB)

Hello,

I have created a realtime database and connected it to my app
I have used the secret key to access it. I have used the url and project bucket
When I set the rules
{
"rules": {
".read": "true",
".write": "true"
}
}

then I can write and read

when I change to
{
"rules": {
".read": "auth != null",
".write": "auth != null"
}
}

then I can only READ but NOT write!

If I change again to
{
"rules": {
".read": "auth != null",
".write": "true"
}
}

then I can read and write!

  1. Is there anything else I should configure in my realtime database?
  2. Should I remove the secret key? If yes then how do I authenticate users?
  3. When I open the app after a day then at the screen open I receive FIrebaseError: permission denied. BUT even still when I create a new entry or try to read its ok! Why this is happening if the user has not tried to log in?
  4. Should the user be authenticated within the blocks first before gain access to firebase? Or a user can sign in via a different screen and then is allowed to change data to another screen?

I included the aia file without the API and URL

Thank you
Regards
Andreas

Show your relevant blocks.

Note: if you are using the Firebase Experimental Component, then this will not work with secure rules / authentication in place.

What secret key ? Hopefully not this:

yes! That secret key! It was the only way to make it work, otherwise the app just kept crashing or could not write to database

I used also this one
I can read BUT not write

also as you will see in the blocks I dont send any info about UID and still have access unless the email is just enough

{
  "rules": {
    "some_path": {
      "$uid": {
        // Allow only authenticated content owners access to their data
        ".read": "auth !== null && auth.uid === $uid",
        ".write": "auth !== null && auth.uid === $uid"
      }
    }
  }
}

So if I need to make a chat app or similar is best to discard the firebase extension and go with the web component?

Which extension is it? (I was previously referring to the native firebase component, not an extension)

Perhaps the extension developer can help ?

You should not really ever need to use the database secrets key....

I apologize..
Its the native firebase component as you mentioned it. The extension is for authenticator.

Did someone used the native firebase component for data storing?

I have set these rules:

{
  "rules": {
    "messages": {
      "$uid": {
        // Allow only authenticated content owners access to their data
             ".read": "$uid === auth.uid",
        ".write": "$uid === auth.uid"
      }
    }
  }
}

and used the below block

image

I have used it as well without the ''messages/'' part because I have set the bucket in the settings..

When I try to write data as above then I get no error message for some reason but no data is stored.
When I try to read then I get an error ''permission denied''

Maybe I am doing something wrong with the blocks code?
Where ever I read they say to authenticate before writing or sending, but how?
Authenticate once or every time before I send data and with which way/key to authenticate?

PS when I set rules of firebase to true then I can read and write

Thank you!

You canot use the native firebase component when authentication/secure rules are in place. There are no methods to handle them.

I am going to send you off here:

thanks for the link..

I have created the block to register but I cannot see any user being created in firebase.
When I paste the url from blocks to my browser with the API key then I can see my console and an empty directory /accounts:signUp

Also the articles says about saving the return values. Where can I find the return value?

Web1.GotText event will return the responseContent.

I have used the GotText and I received the following:
"append .json to your request URI to use REST API"

any idea what this is?

Also

This is form the tutorial

is this supposed to create a new user or get the info from an existing one? Because this is in the section "sign up user"

Hi @_rockingadget,
instead to use webcomponent use FirebaseManager Extension it easier

Best Regards
Marco

Hi Marco,

I tried to use the extension but it has been said that it cannot work with firebase rules.

Thanks I will give it a try and come back to you! :slight_smile:

From my guide:

image

Your blocks

image

are you surprised it does not work if you do not copy correctly ?

You mention in the post to use a dictionary in order to correctly set the dataToWrite.
Could you tell me where I can find that dictionary? Is data to write the TAG?

However I used your code and managed to register user but cannot write data.
Data path I used my firebase URL is that correct?

Id Token can I use the one I got back from response after sign up or should I refresh?

Thanks!

No!!
I just masked the entries with **** for privacy! In the actual code I have it correctly

Sorry I forgot to mention

I disagree

this (which is your firebase project url):
image

is nothing like this, which is a set part of the url, nothing to do with your firebase project url...

image

Hi, excuse me who said the Firebase manager extension cannot use the rules, it is absolutely wrong.
If You check, I use in my sample the same rules that You want to use for your project

Hi Marco,

No need to accuse anyone. I just read in some posts that the experimental component for firebase cannot be used with authorization rules etc.. Also while trying to use the component I could not access the database with rules other than READ, WRITE TRUE.

Can you please quide me how to set the field "data to write" correctly with the dictionary as you mention in your post about the component you made?
Also "data path" should be my firebase URL?

Thanks!

@Marco_Perrone

image

regarding path data
you join global project ID + global Uid +"/" + some text
so my question is

  1. if I dont want to write to a bucket "shopping list" then I leave this blank or just put my firebase url?
  2. is the Uid something you created to keep track of your list? If not then theUid should be the localid we receive from firebase?
  3. I just need to write a simple hello to database so I would know that it works!

PS

I have set up your shopping list example
I have registered user successfully
I try to add an item but lets me press the add item button only if I take a photo. When I take photo, enter the name and quantity I press add add item but I get warning "NOT FOUND"
Did I do something worng?
I initialised both storage and database and set the rules you provided

ps2

I have changed the block code and added my project id
I have created a bucket shoppinglist in the firebase, should I create one for firestore?

Regarding the screenshot I have changed the info in the second arrow but I cannot figure out what to put in the first arrow

@Marco_Perrone