Problem accessing the firebase reference URL directly for firebase real-time database.
Observation 1:
The project is in IoS, I have the following code in AppDeleage:
// Set up the Default DB FirebaseApp.configure()
// Set up the SecondDB FirebaseApp.configure(name: "secondDB", options: secondDBOptions)
I have no problem adding record in the DB1, using the .read != null rules. I have also set up the same rules .read != null thinking that all authenticated user will be able to access the data.
The code at one of the view controller to retrieve data from SecondDB looks something like:
guard let secondDBNews = FirebaseApp.app(name: "secondDBNews") else { assert(false, "Could not retrieve News") }
let usersDB = Database.database(app: secondDBNews).reference().child(mainDelegate.firebaseEnvironment).child("Users").child(String(Auth.auth().currentUser?.uid ?? ""))
usersDB.queryOrdered(byChild: "Email").observeSingleEvent(of: .childAdded, with: { snapshot in ... ... ...
The above seems fine, and readable when .read = true (anyone can read). However, when it is set to .read != null, the error indicates that it does not have the permission.
Observation 2:
The default one has a URL of https://DefaultDB-1234.firebaseio.com/
The second database has a URL like: https://SeconDB-1234-abc.firebaseio.com/
2 Databases - Default & Second:
For the first one, I can load the URL as such in the browser: https://defaultDB-1234.firebaseio.com/Dev/User1/Projects
DefaultDB contains data:
And it will display the data under the tree.
The secondDB also contains data.,
However, when I attempt to load the URL in the browser: eg. https://SecondDB-1234-abc.firebaseio.com/Dev/Article/Day1
Instead of loading the data from the SecondDB, it actually resolves to load the DefaultDB, and tell me that the data is NULL, even though there are data there.
Result shows null:
Questions:
- Are both observations related to each other?
- Is there specifically any authentication configuration that I have missed?