Created
June 24, 2018 20:08
-
-
Save SamStudio8/17dee9abe81e0f977e1453f340674ca7 to your computer and use it in GitHub Desktop.
python-fitbit intraday heart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import fitbit | |
import gather_keys_oauth2 as Oauth2 | |
import datetime | |
CLIENT_ID = 'YOUR CLIENT' | |
CLIENT_SECRET = 'YOUR SECRET' | |
server = Oauth2.OAuth2Server(CLIENT_ID, CLIENT_SECRET) | |
server.browser_authorize() | |
ACCESS_TOKEN = str(server.fitbit.client.session.token['access_token']) | |
REFRESH_TOKEN = str(server.fitbit.client.session.token['refresh_token']) | |
auth2_client = fitbit.Fitbit(CLIENT_ID, CLIENT_SECRET, oauth2=True, access_token=ACCESS_TOKEN, refresh_token=REFRESH_TOKEN) | |
hr = auth2_client.intraday_time_series('activities/heart', base_date='2018-06-08', detail_level='1sec') | |
for record in hr["activities-heart-intraday"]["dataset"]: | |
print record["time"], record["value"] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment