![](/img/trans.png)
[英]Change google-service.json from android studio to firebase_option.dart on flutter project
[英]Firebase authentication and google-service.json
我是 Firebase 的新手。 After reading Firebase doc, my understanding is that if I download google-service.json
and drop it to Application folder of Android Studio project, the Firebase lib will do authentication under the hood so that I can access any of Firebase services storage
, database
etc .
我將 Firebase 存儲規則設置為僅在客戶端經過身份驗證時才允許allow read, write: if request.auth;= null;
但我收到了這個錯誤
User does not have permission to access this object.
如果我刪除if request.auth != null
部分,它工作正常。
誰能幫我理解google-service.json
的用途是什么?
如果這個 json 不用於認證,推薦什么認證?
提前致謝。
google-service.json
中的配置數據允許您的 Android 應用程序在 Google 的服務器上找到其 Firebase 項目。
鑒於安全規則正在影響您的代碼是否有效,您的應用似乎可以正常訪問項目。
所以問題不在於將應用程序連接到項目,而在於您將用戶登錄的代碼中。不可能說出問題所在,因為您沒有共享代碼,但您需要檢查是否有在調用存儲 API 之前當前登錄的用戶:
if (FirebaseAuth.getInstance().getCurrentUser() != null) {
... call to Storage here
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.