Firebase Cloud Firestore无法正常工作

Lakshay dutta

我正在构建使用Cloud Firestore的应用程序。问题是Firestore无法正常工作。这是我正在使用的代码

达特

class Db{

  // collection reference
  static final CollectionReference _collectionReference = Firestore.instance.collection("codes");

  static Future addOrUpdateCode(String code , double lat , double long) async {
    return await _collectionReference.document(code).setData({
      'lat':lat,
      'long':long
    });
  }

}

我已经在pubspec.yaml中添加了这一行

cloud_firestore: ^0.13.7

我收到这些错误

I/BiChannelGoogleApi(13145): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@b61eba8
W/Firestore(13145): (21.3.0) [FirestoreCallCredentials]: Failed to get token: com.google.firebase.FirebaseException: An internal error has occurred. [ yRequests to this API securetoken.googleapis.com method google.identity.securetoken.v1.SecureToken.GrantToken are blocked.�
W/Firestore(13145): #type.googleapis.com/google.rpc.Helpq
W/Firestore(13145): o
W/Firestore(13145):  Google developer console API keyKhttps://console.developers.google.com/project/280924879656/apiui/credential ].
I/BiChannelGoogleApi(13145): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@b61eba8
W/Firestore(13145): (21.3.0) [FirestoreCallCredentials]: Failed to get token: com.google.firebase.FirebaseException: An internal error has occurred. [ yRequests to this API securetoken.googleapis.com method google.identity.securetoken.v1.SecureToken.GrantToken are blocked.�
W/Firestore(13145): #type.googleapis.com/google.rpc.Helpq
W/Firestore(13145): o
W/Firestore(13145):  Google developer console API keyKhttps://console.developers.google.com/project/280924879656/apiui/credential ].
I/BiChannelGoogleApi(13145): [FirebaseAuth: ] getGoogleApiForMethod() returned Gms: com.google.firebase.auth.api.internal.zzaq@b61eba8

在云控制台中启用了以下API

在此处输入图片说明

通过Firebase中启用的电子邮件/密码注册

我正在使用这些规则

rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if false;
    }
  }
}

我相信足够的信息。感谢您的时间。

罗尼·罗斯顿

Firestore安全规则配置不正确。请参阅Cloud Firestore安全规则入门

既然您提到要实现Firebase身份验证,那么您将需要像它们提供的示例一样的东西:

// Allow read/write access on all documents to any user signed in to the application
service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth != null;
    }
  }
}

但是请注意,您可能还希望拥有通过Custom Tokens完成的多级管理请参阅创建自定义令牌,您可能最终会得到类似规则的内容,该规则允许管理员访问所有内容,然后从此处缩小访问范围,例如:

service cloud.firestore {
  match /databases/{database}/documents {
    match /{document=**} {
      allow read, write: if request.auth.token.admin == true;
    }
    match /users/{userId} {
      allow read, write: if request.auth.uid == userId;
    }
  }
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Firebase / Cloud Firestore:onSnapshot()与on()

来自分类Dev

Firebase + PHP - Cloud Firestore

来自分类Dev

Firebase无法正常工作

来自分类Dev

Firebase 无法正常工作

来自分类Dev

Vue Firebase firebase / auth无法正常运行,但是firebase / firestore可以正常工作。“认证不是函数”

来自分类Dev

关于 firebase/cloud firestore 的困惑

来自分类Dev

Firebase .on('value')无法正常工作

来自分类Dev

Firebase服务无法正常工作

来自分类Dev

Firebase limitToFirst无法正常工作

来自分类Dev

Firebase orderbypriority无法正常工作

来自分类Dev

Firebase网站无法正常工作

来自分类Dev

Firebase FaceBookAuthUI无法正常工作?

来自分类Dev

Firebase查询无法正常工作

来自分类Dev

Firebase Cloud Function无法触发

来自分类Dev

Flutter cloud_firestore持久性即使启用也无法正常工作

来自分类Dev

无法将Storage Firebase映像正确链接到Cloud Firestore

来自分类Dev

无法使Google Cloud Messaging正常工作

来自分类Dev

Firebase Cloud Firestore-从参考访问集合

来自分类Dev

带地图的Firebase Cloud Firestore安全规则

来自分类Dev

Flutter从Firebase Cloud Firestore返回完整阵列

来自分类Dev

.add() in firebase cloud firestore 嵌套对象

来自分类Dev

Firebase 函数未针对 Cloud Firestore 触发

来自分类Dev

Android:Firebase ChildEventListener()无法正常工作

来自分类Dev

Firebase CocoaPods安装无法正常工作

来自分类Dev

firebase.auth()。onAuthStateChanged无法正常工作

来自分类Dev

带有Firebase的Cordova无法正常工作

来自分类Dev

Firebase查询无法正常工作并崩溃

来自分类Dev

Android Firebase createUser()无法正常工作

来自分类Dev

Android Firebase getValue()无法正常工作

Related 相关文章

热门标签

归档