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

Fixes for todoist and oura #8

Open
wants to merge 2 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
11 changes: 8 additions & 3 deletions oura/oura_downloader.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,8 @@
"\n",
"* Go to the Developer Section of the Oura Cloud (https://cloud.ouraring.com/oauth/developer).\n",
"* Go to “My Applications” and create a new application by clicking on “New Application”.\n",
"* Fill out the form fields with your data.\n",
"* Fill out the form fields with your data. You need to check `Allow client-side authentication (grant-type token)`\n",
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe only one of them is needed, not sure which one.

" and `Allow server-side authentication (grant-type code)`.\n",
"* Set your callback URL as http://localhost:65010/oura_auth\n",
"* After saving the form, copy your \"Client ID\" and \"Client Secret\" from your Oura application, \n",
"* Inside the directory, copy the file credentials-sample.json and create credentials.json\n",
Expand Down Expand Up @@ -151,7 +152,11 @@
"# this script to start server \n",
"# then visit provided url to complete process, generate token and copy\n",
"# Comment out once completed\n",
"# %run ./oura_server.py"
"# %run ./oura_server.py\n",
"\n",
"# to stop the execution, interrupt the server execution to be\n",
"# able to proceed next, press Kernel -> Interrupt (alternatively, \n",
"# you can trigger the server in a separate window and not in jupyter)"
]
},
{
Expand Down Expand Up @@ -466,7 +471,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
6 changes: 0 additions & 6 deletions oura/oura_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
oura_cr = credentials['oura']
CLIENT_SECRET = oura_cr['CLIENT_SECRET']
CLIENT_ID = oura_cr['CLIENT_ID']
# ACCESS_TOKEN = oura_cr['ACCESS_TOKEN']


from flask import Flask, abort, request
Expand All @@ -26,10 +25,8 @@ def homepage():

def make_authorization_url():
# Generate a random string for the state parameter
# Save it for use later to prevent xsrf attacks
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think xsrf attacks for a thing which runs for a 30 seconds on localhost is pretty safe.

from uuid import uuid4
state = str(uuid4())
save_created_state(state)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is simply not defined anywhere -> doesn't work

params = {"client_id": CLIENT_ID,
"response_type": "code",
"state": state,
Expand Down Expand Up @@ -60,9 +57,6 @@ def oura_redir():
if error:
return "Error: " + error
state = request.args.get('state', '')
if not is_valid_state(state):
# Uh-oh, this request wasn't started by us!
abort(403)
code = request.args.get('code')

return "got an access token! %s" % get_token(code)
Expand Down
7 changes: 4 additions & 3 deletions todoist/todoist_data_analysis.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -501,11 +501,12 @@
},
{
"cell_type": "code",
"execution_count": 18,
"execution_count": 42,
"metadata": {},
"outputs": [],
"source": [
"# Set Year\n",
"# Set Year - must have at least some December data for the code below to work\n",
"# i.e. it should work fine for years which have already finished\n",
"target_year = 2018"
]
},
Expand Down Expand Up @@ -978,7 +979,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.2"
"version": "3.7.4"
}
},
"nbformat": 4,
Expand Down
Loading