LoginSignup
6
4

More than 3 years have passed since last update.

firestoreのcollectionGroupのデータ取得で `The caller does not have permission to execute the specified operation.`

Last updated at Posted at 2020-07-10

firestoreのcollectionGroupを使うと下記のようなエラーが出た

こんな権限エラーが出る…

Error: [firestore/permission-denied] The caller does not have permission to execute the specified operation.

Native Firebase

NativeFirebaseError: [firestore/permission-denied] The caller does not have permission to execute the specified operation.

解決 - セキュリティールールを正しく書き換えよう!

firestore Security Rulesを確認してください。

collectionGroupで下の階層のサブコレクションにアクセスするには
match /{path=**}/コレクション名/{documentId}
の様に上の階層をカスケードしてあげるとPermissionのエラーが消えます!

rules_version = '2';
 service cloud.firestore {
    match /databases/{database}/documents {
      // 認証済み
      function isAuthenticated() {
        return request.auth.uid != null
      }

       // コレクショングループの所
       match /{path=**}/followor_ids/{followerIds} {
        allow read, write: if isAuthenticated();
      }
    }
 }

こんなコードを書いてる時に発生します!


firestore().collectionGroup(COLLECTION_NAME).where('ids', 'array-contains', uid).get()

参考

Collection Group permissions for Firestore - by stackoverflow

6
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
6
4