Tôi đang cố gắng acsess dữ liệu trên firebase từ python (2.7).Xác thực người dùng Firebase trong python
Dưới đây là quy tắc của tôi (trên firebseio.com):
{
"rules": {
"user": {
"$uid": {
".read": "auth != null && auth.uid == $uid",
".write": "auth != null && auth.uid == $uid"
}
}
}
}
Đây là một ảnh chụp màn hình của databse của tôi:
Và cuối cùng, mã python của tôi:
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
Bây giờ tôi không thể tìm cách lấy dữ liệu và gửi dữ liệu đến và đi từ firebase. Tôi tryed useing dòng: result = firebase.get('/users', None, {'print': 'pretty'})
, Nhưng nó mang lại cho tôi lỗi này:
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',))
Bất cứ ai cũng có thể cung cấp cho tôi với một mã làm việc?
Cảm ơn trước,
Zvi Karp
Nếu Im không sử dụng DSN thì sao? – marciokoko