Use firebase auth
This commit is contained in:
@@ -4,7 +4,9 @@ import time
|
|||||||
from firebase import firebase
|
from firebase import firebase
|
||||||
|
|
||||||
BASE_URL = 'https://pocloud-ff2c9.firebaseio.com'
|
BASE_URL = 'https://pocloud-ff2c9.firebaseio.com'
|
||||||
fbdb = firebase.FirebaseApplication(BASE_URL, None)
|
auth = firebase.FirebaseAuthentication('cFjVoqsVX6IRXwhBOqEi9FPrM3249DImRjsRiQM1', 'api@henry-pump.com')
|
||||||
|
|
||||||
|
fbdb = firebase.FirebaseApplication(BASE_URL, authentication=auth)
|
||||||
|
|
||||||
def set_firebase_channel(deviceId, device_type, channel, value, timestamp):
|
def set_firebase_channel(deviceId, device_type, channel, value, timestamp):
|
||||||
"""Sets the value of a firebase channel."""
|
"""Sets the value of a firebase channel."""
|
||||||
@@ -16,6 +18,11 @@ def set_firebase_channel(deviceId, device_type, channel, value, timestamp):
|
|||||||
'timestamp': timestamp
|
'timestamp': timestamp
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hist_value = {
|
||||||
|
'value': value,
|
||||||
|
'timestamp': timestamp
|
||||||
|
}
|
||||||
|
|
||||||
channels_url = "/devices/{}/{}/channels/{}".format(deviceId, device_type, channel)
|
channels_url = "/devices/{}/{}/channels/{}".format(deviceId, device_type, channel)
|
||||||
chan_result = fbdb.patch(channels_url, channel_value,
|
chan_result = fbdb.patch(channels_url, channel_value,
|
||||||
connection=None,
|
connection=None,
|
||||||
@@ -25,7 +32,7 @@ def set_firebase_channel(deviceId, device_type, channel, value, timestamp):
|
|||||||
|
|
||||||
|
|
||||||
history_url = "/devices/{}/{}/history/{}".format(deviceId, device_type, channel)
|
history_url = "/devices/{}/{}/history/{}".format(deviceId, device_type, channel)
|
||||||
result = fbdb.post(history_url, channel_value,
|
result = fbdb.post(history_url, hist_value,
|
||||||
connection=None,
|
connection=None,
|
||||||
params={'print': 'pretty'},
|
params={'print': 'pretty'},
|
||||||
headers={'X_FANCY_HEADER': 'VERY FANCY'})
|
headers={'X_FANCY_HEADER': 'VERY FANCY'})
|
||||||
|
|||||||
Reference in New Issue
Block a user