-
Notifications
You must be signed in to change notification settings - Fork 45
/
firebase.py
26 lines (21 loc) · 881 Bytes
/
firebase.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import datetime
import pyrebase
from env import auth_cred
class Firebase:
def __init__(self):
pass
def authenticate(self):
self.firebase = pyrebase.initialize_app(
{
"apiKey": auth_cred["API_KEY"],
"authDomain": auth_cred["AUTH_DOMAIN"],
"databaseURL": auth_cred["DATABASE_URL"],
"storageBucket": auth_cred["STORAGE_BUCKET"]
}
)
self.db = self.firebase.database()
self.auth = self.firebase.auth()
self.user = self.auth.sign_in_with_email_and_password(auth_cred["EMAIL"], auth_cred["PASS"])
self.uid = self.user["localId"]
def push(self, result):
self.db.child("dummy").child(auth_cred["B_ID"]).update({"current_result": result, "last_updated": str(datetime.datetime.now())}, self.user["idToken"])