Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix auth header and update requirements #13

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions config/fitbit_wrapper_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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://<yourpublicurl>/fitbitAuthCallback' # Add your redirect URI here.

# Decide which information the FitBit.py should have access to.
# Options: 'activity', 'heartrate', 'location', 'nutrition',
Expand Down
9 changes: 7 additions & 2 deletions coreSrc/fitbitPyWrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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).decode()
headers = {
'Authorization': 'Basic %s' % auth_header,
'Content-Type' : 'application/x-www-form-urlencoded'
Expand Down Expand Up @@ -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).decode()
headers = {
'Authorization': 'Basic %s' % auth_header,
'Content-Type' : 'application/x-www-form-urlencoded'
Expand Down
7 changes: 3 additions & 4 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -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