I've been using FireStore for a project that works fine in the browser, but when I port the code to Expo, running on a iOS 11.2 iPhone X in the simulator, it keeps raising Error: Missing or insufficient permissions.
Auth is working fine, and when I check the client in the Firestore collection object, the appropriate UID is set, and testing the same code in the browser, everything works perfectly (no permissions problem). What I'm trying to say is that I'm 95% certain that the issue is with the Firebase lib/react native/expo combination, rather than with my code. Especially since it seems that making a call to Firestore in the browser, there are headers set, but when debugging the call in Reactotron (from Expo), it looks like the call the Firebase lib is making has no headers at all.
I doubt it makes a difference, but here are my auth rules:
service cloud.firestore {
match /databases/{database}/documents {
match /UserData/{userID} {
allow read, write: if request.auth.uid == userID;
}
match /MemberData/{userID} {
allow read: if request.auth.uid == userID;
}
}
}
The call I was trying to make (and there is definitely data in the doc) is the following:
profile = (await UserDataCollection.doc(`${idToken.uid}`).get()).data();
I'm curious if anyone else has run into this problem, and if so, are there any workarounds to make Firestore work?
As per previous comments, downgrading to 4.6.2 seems to fix the issue. I'm not sure the exact root cause but the behaviour of how the auth headers are sent seem to have changed (so potentially something there?). I'll update my answer if I get time to investigate further. Happy for one of the Firebase team to contact me for my account details if they want to verify on their side.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With