Skip to content

Commit

Permalink
Merge a5b8699 into 87ca1c0
Browse files Browse the repository at this point in the history
  • Loading branch information
maplebed committed Dec 28, 2020
2 parents 87ca1c0 + a5b8699 commit 5a678f1
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
12 changes: 8 additions & 4 deletions myfitbit/auth.py
Expand Up @@ -4,6 +4,8 @@
import logging
import os
import time
import webbrowser
import urllib

import requests

Expand All @@ -15,7 +17,7 @@

class RedirectServer(object):
IP = '127.0.0.1'
PORT = 18189
PORT = 8189
URL = 'http://localhost:{}/auth_code'.format(PORT)
def __init__(self):
self.result = None
Expand Down Expand Up @@ -114,9 +116,11 @@ def ensure_access_token(self):
access_token = self.get_access_token()

now = int(time.time())
if now > access_token['time'] + access_token['expires_in'] - 30:
log.info('Access token is expired')
access_token = self.get_access_token_refresh(access_token['refresh_token'])
print(access_token)
print("skipping access token time check for validity")
# if now > access_token['time'] + access_token['expires_in'] - 30:
# log.info('Access token is expired')
# access_token = self.get_access_token_refresh(access_token['refresh_token'])

if self.access_token is not access_token:
access_token['time'] = now
Expand Down
2 changes: 1 addition & 1 deletion myfitbit/sync.py
Expand Up @@ -33,7 +33,7 @@ def sync_ranged_data(self, name, client_fn):
the FitBit API to the local data store, one month at a time
'''
fn = self.datastore.filename
month = 2015 * 12 # TODO use profile['memberSince']
month = 2010 * 12 # TODO use profile['memberSince']
while 1:
date_start = date(month // 12, month % 12 + 1, 1)
month += 1
Expand Down

0 comments on commit 5a678f1

Please sign in to comment.