【发布时间】:2020-06-23 15:09:49
【问题描述】:
我想将我的 firebase 对象的规则选项卡设置为只读。
当我取下写入包时,尝试将文件添加到我的存储时,我的 python 上出现错误。
下面是我的代码
import firebase_admin
config={
"apiKey": "xxx",
"authDomain": "xxx",
"databaseURL": "xxx",
"projectId": "xxx",
"storageBucket": "xxx",
"messagingSenderId": "xxx",
"appId": "xxx",
"measurementId": "xxx"
}
# Initialize connection to firebase_admin
firebase = firebase_admin.initialize_app(config)
storage = firebase.storage()
path_on_cloud ="Data quality report/Data quality report.py"
path_local = "Data_quality_report.py"
storage.child(path_on_cloud).put(path_local)
我的规则标签是
service firebase.storage {
match /b/{bucket}/o {
match /{allPaths=**} {
allow read;
allow write: if request.auth != null;
}
}
}
你们知道如何解决这个问题吗?
提前谢谢你
【问题讨论】:
-
能否请您添加您收到的错误信息。谢谢!
-
嗨西詹!谢谢您的答复。错误是
"code": 403, "message": "Permission denied. Could not perform this operation"我相信是因为 .put(path_local) 中使用的 put 方法 -
这看起来确实是一个权限问题,但如前所述,您已经拥有由 firebase.google.com/docs/storage/security/start?authuser=1 的 firebase 安全规则定义的正确存储规则。您能否确认您是否拥有该项目的正确权限?然而,这看起来像是一个常见问题stackoverflow.com/questions/50432995/…
-
感谢您的评论,您知道在您提供给我的示例中应该用什么替换 idToken 吗?
标签: python firebase google-cloud-firestore