-1

Hello i 'm using http Flutter to get data from Firebase Realtime db

I want access data by using user id not token

I try this :

My Realtime db rules :

{
  "rules": {
      "$user_id": {
        ".read": "$user_id === auth.uid",
        ".write": "$user_id === auth.uid",
      }
  }
}

and url :

final url = 'https://firebaseio-demo.firebaseio.com/Questions/$id.json?user_id=$userId';

but its not work :(

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Sparkat JKS
  • 149
  • 1
  • 10
  • "I want access data by using user id not token" That would be highly insecure, given that the UID of a user is merely an identifier for them and not any form of authentication. See https://stackoverflow.com/questions/37221760/firebase-is-auth-uid-a-shared-secret – Frank van Puffelen Jan 19 '21 at 21:16

1 Answers1

0

Indexes for the realtime database need to be defined on the place in the JSON where you run the query. Since you run a query on /Question, that's where you also need to define your index:

{
  "rules": {
    "Questions": {
      ".indexOn": "user_id"
    }
  }
}

Also see the Firebase documentation on indexing your data.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807