简体   繁体   English

Python-Firebase(401)未经授权的错误

[英]Python-Firebase (401) Unauthorised error

Been trying to retrieve data from my firebase however I keep getting HTTPError: 401 Client Error: Unauthorized. 一直试图从我的firebase检索数据但是我一直得到HTTPError: 401 Client Error: Unauthorized. Been using https://pypi.python.org/pypi/python-firebase/1.2 as a guide. 使用https://pypi.python.org/pypi/python-firebase/1.2作为指南。 Tried adjusting the authentication code but got nowhere. 尝试调整身份验证代码但无处可去。 How would I retrieve data from my firebase 我如何从我的firebase中检索数据

from firebase import firebase

firebase =  firebase.FirebaseApplication('(my firebase url)',None)

result = firebase.get('/User',None)

print (result)

Go to in Firebase Console > Database >Rules and change 转到Firebase控制台>数据库>规则并进行更改

 ".read": "auth != null",
 ".write": "auth != null"

to: 至:

".read": "auth == null",
".write": "auth == null"

Provide the authentication information to firebase, 向firebase提供身份验证信息,

from firebase import firebase
authentication = firebase.FirebaseAuthentication('YOUR SECRET', 'user@gmail.com', extra={'id': 123})
fireapp = firebase.FirebaseApplication('DATABASE_URL',  authentication=authentication)

and make sure the database rules are, 并确保数据库规则是,

 ".read": "auth != null",
 ".write": "auth != null"

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

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