简体   繁体   English

是什么原因导致“权限被拒绝” - 使用FIREBASE和FLUTTER消息

[英]what causes “permission denied”-message with FIREBASE and FLUTTER

I've got the error 我有错误

'W/SyncTree(31625): Listen at /address failed: DatabaseError: Permission denied' 'W / SyncTree(31625):侦听/地址失败:DatabaseError:Permission denied'

while sending a request to firebase with an anonymous firebase user and without fancy firebase database rules :) . 同时使用匿名firebase用户向firebase发送请求,而没有花哨的firebase数据库规则:)。 ..and i want to find out what causes this message. ..我想找出导致这条消息的原因。

EDIT: error is the same with an existing user, means user signIn seems to work but accessing database not. 编辑:错误是与现有用户相同,意味着用户signIn似乎工作但不访问数据库。

What i've done so far: 到目前为止我做了什么:

  • Set up firebase (including adding google_service.json, dependencies in pubspec.yaml) - works so far 设置firebase(包括添加google_service.json,pubspec.yaml中的依赖项) - 到目前为止工作
  • creating login as follows (like in example from google link ): 按如下方式创建登录(例如来自google 链接的示例):

     Future<String> _testSignInAnonymously() async { final FirebaseUser user = await _auth.signInAnonymously(); assert(user != null); assert(user.isAnonymous); assert(!user.isEmailVerified); assert(await user.getIdToken() != null); assert(user.providerData.length == 1); assert(user.providerData[0].providerId == 'firebase'); assert(user.providerData[0].uid != null); assert(user.providerData[0].displayName != null); assert(user.providerData[0].photoUrl == null); assert(user.providerData[0].email != null); final FirebaseUser currentUser = await _auth.currentUser(); print(currentUser.uid); print(currentUser.isAnonymous); assert(user.uid == currentUser.uid); return 'signInAnonymously succeeded: $user'; } 
  • the print statement provides a userId (and this id is also in firebase auth section) --> seems to me that i've got an logged in user print语句提供了userId(这个id也在firebase auth部分) - >在我看来我已经登录了用户

  • implement kind of initialization like in the google example ( link ): 像谷歌示例( 链接 )中实现一种初始化:

     Future<void> main() async { final FirebaseApp app = await FirebaseApp.configure( name: 'mydbName', options: const FirebaseOptions( googleAppID: 'myAppId', apiKey: 'myApiKey', databaseURL: 'myUrl', ), ); runApp(new MyApp(app)); } 
  • on another stateful widget in state i try to request some firebase data: 在州的另一个有状态小部件我尝试请求一些firebase数据:

     void initState() { final FirebaseDatabase database = new FirebaseDatabase(app: widget.app); database.reference().child('address').once().then((DataSnapshot snapshot) { print('Connected to database and read ${snapshot.value}'); }); super.initState(); } 
  • i've removed all rules in firebase except: 我删除了firebase中的所有规则,除了:

     ".read": "auth != null", ".write": "auth != null", 
  • i use an SHA-1 certificate/fingerprint in my firebase android app 我在我的firebase android app使用SHA-1证书/指纹

  • i use the same firebase database with an firebase ios app without any problem while using anonymous users 在使用匿名用户时,我使用与firebase ios app相同的firebase数据库,没有任何问题

What i need: 我需要的:

I need some hint how to find out if there's any problem with that initialization code or with the user login or something else 我需要一些提示如何找出初始化代码或用户登录或其他问题是否有任何问题

It seems the database is not correctly addressed in FirebaseApp.configure( 似乎FirebaseApp.configure(没有正确地解决数据库FirebaseApp.configure(

FirebaseDatabase.instance.reference().child(...)

would use the default database of the project configured in google-services.json 将使用google-services.json配置的项目的默认数据库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM