我正在嘗試從python(2.7)交流firebase上的數據。python中的Firebase用戶身份驗證
這裏是我的規則(上firebseio.com):
{
"rules": {
"user": {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid"
}
}
}
}
這裏是我的DATABSE的截圖:
而在去年,我的Python代碼:
from firebase import firebase
from firebase.firebase import FirebaseApplication, FirebaseAuthentication
DSN = 'https://<my name>.localhost'
EMAIL = '[email protected]'
authentication = FirebaseAuthentication(EMAIL, True, True, extra={'id': '<the user id>'})
firebase = FirebaseApplication(DSN, authentication)
firebase.authentication = authentication
print authentication.extra
user = authentication.get_user()
print user.firebase_auth_token
現在我無法找到如何獲取數據並向Firebase發送數據和從Firebase發送數據。 我tryed期運用行:result = firebase.get('/users', None, {'print': 'pretty'})
,但它給我這個錯誤:
ConnectionError: HTTPSConnectionPool(host='<my name>.localhost', port=443): Max retries exceeded with url: /users/.json?print=pretty&auth=<the token code of the user> (Caused by NewConnectionError('<requests.packages.urllib3.connection.VerifiedHTTPSConnection object at 0x02A913B0>: Failed to establish a new connection: [Errno 11001] getaddrinfo failed',))
誰能給我提供一個工作代碼?
由於提前,
茲維·卡普
如果我不使用DSN會怎麼樣? – marciokoko