相关疑难解决方法(0)

firestore:PERMISSION_DENIED:缺少权限或权限不足

我收到了错误

gettingdocuments.com.google.firebase.firestore.FirebaseFirestoreException:PERMISSION_DENIED:权限丢失或不足.

对于else语句中的以下代码

db.collection("users")
        .get()
        .addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
            @Override
            public void onComplete(@NonNull Task<QuerySnapshot> task) {
                 if (task.isSuccessful()) {
                     for (DocumentSnapshot document : task.getResult()) {
                         s(document.getId() + " => " + document.getData());
                     }
                 } else {
                     s("Error getting documents."+ task.getException());
                 }
             }
         });
Run Code Online (Sandbox Code Playgroud)

android firebase google-cloud-firestore

53
推荐指数
14
解决办法
5万
查看次数

Firebase Firestore使用Expo(React Native)丢失或权限不足

我一直在使用FireStore来实现在浏览器中运行良好的项目,但是当我将代码移植到Expo,在模拟器中运行iOS 11.2 iPhone X时,它一直在提升 Error: Missing or insufficient permissions.

Auth工作正常,当我在Firestore集合对象中检查客户端时,设置了相应的UID,并在浏览器中测试相同的代码,一切正常(没有权限问题).我想说的是,我95%确定问题出在Firebase lib/react native/expo组合上,而不是我的代码.特别是因为它似乎在浏览器中调用Firestore,所以有标题设置,但是当在Reactotron(来自Expo)中调试调用时,看起来Firebase lib正在进行的调用根本没有标题.

我怀疑它有所不同,但这是我的身份验证规则:

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;
    }
  }
}
Run Code Online (Sandbox Code Playgroud)

我试图进行的调用(并且文档中肯定存在数据)如下:

profile = (await UserDataCollection.doc(`${idToken.uid}`).get()).data();
Run Code Online (Sandbox Code Playgroud)

我很好奇是否有其他人遇到过这个问题,如果有的话,有什么办法让Firestore工作吗?

ios firebase-security react-native expo google-cloud-firestore

9
推荐指数
1
解决办法
2383
查看次数

Firestore错误-&gt;错误:缺少权限或权限不足

我的应用程序有时会在客户端前端使用Firestore的应用程序中出现此错误(JS Firebase / Firestore SDK库)。我认为这就像一个速率限制问题,但是我在Firebase上的设置是Blaze(即用即付),所以我偶尔会遇到这样的问题吗?

在开发期间,清除我的缓存/等待它/切换会话或浏览器似乎可以解决问题。不知道为什么偶尔会发生这种情况,或者为什么四处逛逛会解决它。

我目前已经firebase.auth().signOut()在我的应用程序中实现了,但是无论何时发生,注销并重新登录似乎都无法解决问题。

这是该问题的我的开发人员控制台堆栈跟踪:

index.js:2177 Firestore error -> Error: Missing or insufficient permissions.
    at new FirestoreError (error.js:149)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromRpcStatus (serializer.js:93)
    at JsonProtoSerializer../node_modules/@firebase/firestore/dist/esm/src/remote/serializer.js.JsonProtoSerializer.fromWatchChange (serializer.js:536)
    at PersistentListenStream../node_modules/@firebase/firestore/dist/esm/src/remote/persistent_stream.js.PersistentListenStream.onMessage (persistent_stream.js:389)
    at persistent_stream.js:331
    at persistent_stream.js:306
    at async_queue.js:83
    at <anonymous>
__stack_frame_overlay_proxy_console__ @ index.js:2177
(anonymous) @ SideMenu.js:91
Promise rejected (async)
componentDidUpdate @ SideMenu.js:88
commitLifeCycles @ react-dom.development.js:11517
commitAllLifeCycles @ react-dom.development.js:12294
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback @ react-dom.development.js:1195
commitAllWork @ react-dom.development.js:12415
workLoop @ react-dom.development.js:12687
callCallback @ react-dom.development.js:1299
invokeGuardedCallbackDev @ react-dom.development.js:1338
invokeGuardedCallback …
Run Code Online (Sandbox Code Playgroud)

javascript google-cloud-firestore

5
推荐指数
0
解决办法
2423
查看次数

Cloud Firestore ReactJS错误:权限丢失或不足

我对Cloud Firestore特别安全的角色相当新,但由于它们非常重要,我宁愿启动围绕它们的项目的新构建.

现在作为一个基本的见解,我有一个仪表板,用户必须使用他们的电子邮件地址和密码登录,然后他们可以访问区域信息等数据.从安全规则开始,我认为我开始时很简单,但正如标题所述我得到的:

Error: Missing or insufficient permissions

我查看了https://firebase.google.com/docs/firestore/solutions/role-based-access

service cloud.firestore {
  match /databases/{database}/documents {
      match /regions/{region} {
        function isSignedIn() {
          return request.auth != null;
        }

        function getRole(rsc) {
          // Read from the "roles" map in the resource (rsc).
          return rsc.data.roles[request.auth.uid];
        }

        function isOneOfRoles(rsc, array) {
          // Determine if the user is one of an array of roles
          return isSignedIn() && (getRole(rsc) in array);
        }

                // Any role can read regions.
        allow read: if isOneOfRoles(resource, ['owner', 'writer', 'commenter', 'reader']); …
Run Code Online (Sandbox Code Playgroud)

firebase reactjs google-cloud-firestore firebase-security-rules

5
推荐指数
0
解决办法
1010
查看次数