I'm trying to read data in a Realtime Database in Firebase but I get an error:
Client doesn't have permission to access the desired data.
This is the code for reading:
final ref = FirebaseDatabase.instance.ref();
final snapshot = await ref.child('data').get();
if (snapshot.exists) {
print(snapshot.value);
} else {
print('No data available.');
}
this is the database structure:
And this is the security rules:
{
"rules": {
".read": true,
".write": true
}
}
I also updated the google-services.json file. Error in Android:
W/PersistentConnection( 8311): pc_0 - Firebase Database connection was forcefully killed by the server. Will not attempt to reconnect. Reason: The database lives in a different region. Please change your database URL to https://xxxx-rtdb.europe-west1.firebasedatabase.app