As you can see this is an issue for many people.
Angular/Fire Package returns Missing or insufficient permissions for get requests that work inside the Firestore Rule Playground.
Example 1:
Store collections and fields.
This is my query:
this.resultCol = this.afs.collection('messages', ref => ref.where('orderId', '==', this.id).orderBy('created', 'desc') );
Source: https://github.com/angular/angularfire/issues/1828
service cloud.firestore {
match /databases/{database}/documents {
match /users/{user} {
allow create: if request.auth != null;
}
match /messages/{message} {
function isConvParticipant() {
return request.auth.uid == request.resource.data.clientId || request.auth.uid == request.resource.data.ownerId;
}
function isLoggedAndExist() {
return request.auth != null && exists(/databases/$(database)/documents/users/$(request.auth.uid));
}
allow get: if isLoggedAndExist();
allow list: if isLoggedAndExist() && request.auth.uid == resource.data.clientId || request.auth.uid == resource.data.ownerId;
allow create: if isLoggedAndExist() && isConvParticipant();
}
}
}
Other people are also having errors: Source: https://github.com/angular/angularfire/issues/2121
Question Why in the firestore simulator is alright but in real action doesn't
For anyone coming on to this question.
First, request.auth might be null so you must check on that as it will error our causing 'missing' permissions. Please check firestore rules monitoring - this will tell you the difference between a disallow and a error. Chances are you are receiving this because of an "ERROR" not because of a disallow.
Secondly, ensure that the user is signed in. You can do this by authStateChanged or AngularFirestoreAuth.user observable.
I figured out that I was receiving that message because of an ERROR. And that's because the authenticated user was not there when it was there in Firebase Admin.