Pyrebase库拒绝了Firebase权限 [英] Firebase Permission Denied with Pyrebase library

查看:95
本文介绍了Pyrebase库拒绝了Firebase权限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经设置了Firebase帐户和数据库.

I have setup a Firebase account and a database.

我已将带有API密钥的配置复制到我的Python代码中.

I have copied the config with the API key into my Python code.

在Python 3.5上我仍然收到401权限被拒绝的错误

I still get a 401 Permission denied error on Python 3.5

import pyrebase
config = {
"apiKey": "*****",
"authDomain": "***-bot.firebaseapp.com",
"databaseURL": "https://***-bot.firebaseio.com",
"storageBucket": "ebo-bot.appspot.com"
}

firebase = pyrebase.initialize_app(config)
db = firebase.database()
data = {"name": "Mortimer 'Morty' Smith"}
db.child("users").child("Morty").set(data)

我的数据库规则设置为:

My database rules are set to:

{
 "rules": {
".read": "auth != null",
".write": "auth != null"
}
}

推荐答案

我试图将数据上传到数据库时遇到了同样的问题. 我重读了以下内容的开头: https://github.com/thisbejim/Pyrebase/blob /master/README.md

I ran into this same issue trying to upload data to the database. I reread the beginning of: https://github.com/thisbejim/Pyrebase/blob/master/README.md

import pyrebase

config = {
  "apiKey": "apiKey",
  "authDomain": "projectId.firebaseapp.com",
  "databaseURL": "https://databaseName.firebaseio.com",
  "storageBucket": "projectId.appspot.com",
  "serviceAccount": "path/to/serviceAccountCredentials.json"
}

firebase = pyrebase.initialize_app(config)

将serviceAccount条目添加到配置中,其中包含可从Firebase下载的密钥的路径.

Add the serviceAccount entry into the configuration with a path to a key that you can download from Firebase.

要到达那里:设置>项目设置>服务帐户>生成新的私钥.

To get there: Settings > Project Settings > Service Accounts > Generate New Private Key.

将该密钥放置在所需的位置,然后将该位置放置在"serviceAccount"路径中.

Put that key in some desired location and put that location in the "serviceAccount" path.

希望有帮助.

这篇关于Pyrebase库拒绝了Firebase权限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆