From 9dee70f40b0de97de5fe79799b665a4d9326634d Mon Sep 17 00:00:00 2001 From: disgustipated Date: Sat, 5 Aug 2023 19:12:52 +0000 Subject: [PATCH 1/3] updated requirements --- requirements.txt | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index c8204f7..39da170 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,4 @@ -falcon==3.1.0 +falcon==3.1.1 falcon_cors==1.1.7 -requests==2.27.1 -gunicorn - +requests==2.31.0 +gunicorn \ No newline at end of file From 9cf9a0a77e572514d866e835e663e5102fe629d3 Mon Sep 17 00:00:00 2001 From: disgustipated Date: Sun, 6 Aug 2023 10:57:59 +0000 Subject: [PATCH 2/3] fix encoding auth header --- README.md | 4 ++-- coreSrc/fitbitPyWrapper.py | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index fc40ebb..2d2a1d0 100644 --- a/README.md +++ b/README.md @@ -16,11 +16,11 @@ NOTE: uses gunicorn (https://docs.gunicorn.org/en/stable/index.html) which is WS - Edit `fitbit_wrapper_config.py` > add client ID and client secret > save. - `pip install -r requirements.txt` in venv of your choice. ```sh - gunicorn -b localhost:8000 fitbit_web_service:app --reload +gunicorn -b localhost:8000 fitbit_web_service:app --reload ``` - Interact with your webservice with dedicated #Keywords: ```sh - http://localhost:8000/processFitbitApi?keyword=todays_steps_real_time +http://localhost:8000/processFitbitApi?keyword=todays_steps_real_time ``` # Keywords diff --git a/coreSrc/fitbitPyWrapper.py b/coreSrc/fitbitPyWrapper.py index 7d7b031..677161c 100644 --- a/coreSrc/fitbitPyWrapper.py +++ b/coreSrc/fitbitPyWrapper.py @@ -47,7 +47,10 @@ def GetAuthorizationUri(self): def GetAccessToken(self, access_code): # Construct the authentication header - auth_header = base64.b64encode(self.dynamic_config['client_id'] + ':' + self.dynamic_config['client_secret']) + #header + strAuthHeader = self.dynamic_config['client_id'] + ':' + self.dynamic_config['client_secret'] + bAuthHeader = strAuthHeader.encode("utf-8") + auth_header = base64.b64encode(bAuthHeader) headers = { 'Authorization': 'Basic %s' % auth_header, 'Content-Type' : 'application/x-www-form-urlencoded' @@ -81,7 +84,9 @@ def GetAccessToken(self, access_code): def RefAccessToken(self, token): # Construct the authentication header - auth_header = base64.b64encode(self.dynamic_config['client_id'] + ':' + self.dynamic_config['client_secret']) + strAuthHeader = self.dynamic_config['client_id'] + ':' + self.dynamic_config['client_secret'] + bAuthHeader = strAuthHeader.encode("utf-8") + auth_header = base64.b64encode(bAuthHeader) headers = { 'Authorization': 'Basic %s' % auth_header, 'Content-Type' : 'application/x-www-form-urlencoded' From 6c59c20b3d0fc739086ba50833f9cc5629f26c86 Mon Sep 17 00:00:00 2001 From: disgustipated Date: Mon, 7 Aug 2023 10:34:26 +0000 Subject: [PATCH 3/3] more auth header fixes --- config/fitbit_wrapper_config.py | 6 +++--- coreSrc/fitbitPyWrapper.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/config/fitbit_wrapper_config.py b/config/fitbit_wrapper_config.py index ae24c30..a968d23 100644 --- a/config/fitbit_wrapper_config.py +++ b/config/fitbit_wrapper_config.py @@ -47,9 +47,9 @@ def _dynamic_config(self): :return: a dictionary of dynamic config required for Fitbit wrapper. """ - CLIENT_ID = 'XXXXX' # Add your client ID here. - CLIENT_SECRET = 'xxxxx' # Add your client secret here. - REDIRECT_URI = 'http://localhost:8000/fitbitAuthCallback' # Add your redirect URI here. + CLIENT_ID = 'XXXX' # Add your client ID here. + CLIENT_SECRET = 'XXXX' # Add your client secret here. + REDIRECT_URI = 'https:///fitbitAuthCallback' # Add your redirect URI here. # Decide which information the FitBit.py should have access to. # Options: 'activity', 'heartrate', 'location', 'nutrition', diff --git a/coreSrc/fitbitPyWrapper.py b/coreSrc/fitbitPyWrapper.py index 677161c..08882de 100644 --- a/coreSrc/fitbitPyWrapper.py +++ b/coreSrc/fitbitPyWrapper.py @@ -50,7 +50,7 @@ def GetAccessToken(self, access_code): #header strAuthHeader = self.dynamic_config['client_id'] + ':' + self.dynamic_config['client_secret'] bAuthHeader = strAuthHeader.encode("utf-8") - auth_header = base64.b64encode(bAuthHeader) + auth_header = base64.b64encode(bAuthHeader).decode() headers = { 'Authorization': 'Basic %s' % auth_header, 'Content-Type' : 'application/x-www-form-urlencoded' @@ -86,7 +86,7 @@ def RefAccessToken(self, token): # Construct the authentication header strAuthHeader = self.dynamic_config['client_id'] + ':' + self.dynamic_config['client_secret'] bAuthHeader = strAuthHeader.encode("utf-8") - auth_header = base64.b64encode(bAuthHeader) + auth_header = base64.b64encode(bAuthHeader).decode() headers = { 'Authorization': 'Basic %s' % auth_header, 'Content-Type' : 'application/x-www-form-urlencoded'