我在通過 python API 訪問我的 firestore 資料時遇到了一些問題。我已經嘗試了其他答案中提到的所有解決方案,但我仍然遇到相同的權限被拒絕問題:
_InactiveRpcError: <_InactiveRpcError of RPC that terminated with:
status = StatusCode.PERMISSION_DENIED
details = "Missing or insufficient permissions."
debug_error_string = "{"created":"@1636057424.408000000","description":"Error received from peer ipv4:x:x:x:x:443","file":"src/core/lib/surface/call.cc","file_line":1068,"grpc_message":"Missing or insufficient permissions.","grpc_status":7}"
>
以下是我使用 API 的方式:
import firebase_admin
from firebase_admin import credentials
from firebase_admin import firestore
cred = credentials.Certificate('/users/88232/cred.json') #correct credentials path - also tried pasting the dictionary directly
firebase_admin.initialize_app(cred)
db = firestore.Client('myapp') #made sure it's the right project's name (I have multiple projects)
doc_ref = db.collection(u'sample').document(u'0SZxt2xXs7n8Vglz8wEu')
doc = doc_ref.get() #error here
我嘗試過的事情:
- 在 API [

uj5u.com熱心網友回復:
我想到了。顯然,問題出在這一行:
db = firestore.Client('myapp')如果我將其更改為:
db = firestore.client()一切都按預期作業。
這也是 Google 官方檔案 ( https://firebase.google.com/docs/reference/admin/python/firebase_admin.firestore ) 中顯示的唯一方法。
我不確定我遵循了哪些指南/演練讓我使用了
Client而不是,client但我無法弄清楚其中的區別。如果有人知道,請在下面評論。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/349398.html下一篇:NullInjectorError:InjectionTokenangularfire2.app.options沒有提供者!2021年
