I would like to set the database rules for my realtime database using the java sdk. I created a FirebaseDatabase object but I wasn't able to find out how to get/set the database rules using it.
val options = FirebaseOptions.builder()
.setDatabaseUrl("https://my-database.europe-west1.firebasedatabase.app/")
.setCredentials(GoogleCredentials.fromStream(File("/path/tom/my/key.json").inputStream()))
.build()
val defaultApp = FirebaseApp.initializeApp(options)
val defaultDatabase = FirebaseDatabase.getInstance(defaultApp);
// and here I would like to fetch the current rules and be able to set the new one
I've found this piece of docs: https://firebase.google.com/docs/database/rest/app-management and tried
println(defaultDatabase.getReference(".settings/rules.json"))
but I got only
com.google.firebase.database.DatabaseException: Invalid Firebase Database path: .settings/rules.json. Firebase Database paths must not contain '.', '#', '$', '[', or ']'
How to do it ?
The .settings
pseudo-node is not exposed in the Java Admin SDK. If you want to manipulate the rules from your Java code, you'll have to call the REST API from there.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments