Comments (7)
@alextruong Thank you for your interest! Unfortunately, most of the OAuth2 authorization is not part of this library. We assume authorization has already been granted. If you use Django, you can try our https://github.com/orcasgit/django-fitbit library, which includes that authorization piece. Alternatively, there is some example authorization code using a CherryPy server in the python-fitbit repo in gather_keys_oauth2.py
from python-fitbit.
Thanks for the quick response! Currently, the code we have is importing the gather_keys_oauth2.py
script and executing some of those functions to authorize, and that's where I was looking to make edits. However it looks like all of the stuff that deals with modifying the authorization URL is hidden inside a third-party library? Is that correct?
We haven't considered using Django, since we're only trying to craft a data-gathering tool. There should be minimum interactivity (run it once, download as much data as is required). Currently, it needs to be run for one user at a time, with a session clearing in between to manually dump token credentials; since the API gives more elegant ways to handle this (prompt
and revoke access), I was wondering if that would be a thing that could happen.
Alternatively, I notice that the your api.py
code makes use of python-requests
; would it be possible to manually handle cookie dumping via that library? Which structures would I need to access from your class?
from python-fitbit.
Sorry @alextruong cookie dumping is beyond my knowledge. You're right that we use a third party library for the authorization: requests-oauthlib
, which is itself a wrapper around oauthlib
. Looking at that library, I don't see anything about a prompt
parameter there though, so I'm not sure how we could go about adding it. Pull requests are always welcome 😄
from python-fitbit.
@brad The prompt
parameter is less a feature of the library, and more a feature of the Fitbit API, actually; it's part of the URL construction to be sent with the request. Here's the section I'm referring to: https://dev.fitbit.com/docs/oauth2/#authorization-page
You'll notice that prompt
is a feature of the authorization protocol a dev can implement. I just have no idea how to do so...
I'd totally submit a PR if I knew how to approach this, heh. :)
from python-fitbit.
So a super hacky way I was able to get around this was to hijack the URL in the OAuth2Server object of the gather_keys_oauth2.py script. Initialize the object:
server = OAuth2.OAuth2Server(client_id, consumer_secret)
Then just pull out the URL directly:
auth_url = server.oauth.authorize_token_url(redirect_uri = server.redirect_uri)[0]
Then you can mangle the URL with whatever parameters (such as prompt) you'd like and then validate afterwards with the modified URL.
I'm still verifying the integrity of the data accessible by this method as opposed to executing browser_authorize()
, as it appears that intraday time series disappears (or maybe there's something wrong on our side), but that's a different story entirely. :)
from python-fitbit.
I've been trying to figure out how to automate text entry into both user and pass text fields with Selenium web driver, however, there doesn't appear to be a way to interact with the current browser session without first opening either a new browser or tab. Any suggestion?
from python-fitbit.
I've since added this feature to the gather_keys_oAuth2.py. Since I am new to Github, I'll simply attach the updated .py file here (see lines 41-53, 61). Note, you can't hit the Fitbit API very often (freq unknown) without getting temporarily blocked. Thanks!
from python-fitbit.
Related Issues (20)
- Problems with Auth 2.0 HOT 3
- Help needed?
- How to get activity statistics by activity type when its started from the tracker?
- unable to get sleep summary data using time_series('sleep') HOT 2
- Source tarball on PyPi does not include tests or tox config
- Error trying to get heart data HOT 4
- Close Chrome tab after validating API HOT 3
- AttributeError: module 'fitbit' has no attribute 'Fitbit' HOT 1
- Works well Locally, but not Deployed
- Add multi-date functionality
- Force sync HOT 1
- wait_for_tstate_lock: ENGINE Waiting for thread Thread-4
- fitbit do not allow callback URLs with http anymore HOT 2
- Add lifetime stats, friends and badges API HOT 1
- [INFO] Repo not maintained anymore ? HOT 13
- Unable to establish connection with Fitbit API
- Exporting Breathing Rate Intraday by Date HOT 10
- urllib failure
- TCX endpoint decoding error error
- Download Skin Temperature and SpO2 data HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from python-fitbit.