From b2461b85955ba59818fd033633008a761b5d4c0f Mon Sep 17 00:00:00 2001 From: Patrick McDonagh Date: Fri, 10 Aug 2018 15:04:26 -0500 Subject: [PATCH] Use firebase auth --- firebase_interface.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/firebase_interface.py b/firebase_interface.py index 6e46676..d979fbc 100644 --- a/firebase_interface.py +++ b/firebase_interface.py @@ -4,7 +4,9 @@ import time from firebase import firebase 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): """Sets the value of a firebase channel.""" @@ -16,6 +18,11 @@ def set_firebase_channel(deviceId, device_type, channel, value, timestamp): 'timestamp': timestamp } + hist_value = { + 'value': value, + 'timestamp': timestamp + } + channels_url = "/devices/{}/{}/channels/{}".format(deviceId, device_type, channel) chan_result = fbdb.patch(channels_url, channel_value, 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) - result = fbdb.post(history_url, channel_value, + result = fbdb.post(history_url, hist_value, connection=None, params={'print': 'pretty'}, headers={'X_FANCY_HEADER': 'VERY FANCY'})