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

时间:2016-08-21 07:28:05

标签: python authentication firebase firebase-realtime-database

尝试从我的firebase检索数据但是我一直在HTTPError: 401 Client Error: Unauthorized.使用https://pypi.python.org/pypi/python-firebase/1.2作为指南。尝试调整身份验证代码但无处可去。我如何从我的firebase中检索数据

from firebase import firebase

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

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

print (result)

2 个答案:

答案 0 :(得分:1)

转到Firebase控制台>数据库>规则和变更

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

为:

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

答案 1 :(得分:0)

向firebase提供身份验证信息,

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

并确保数据库规则为

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