trying garmin workout list - not working
This commit is contained in:
@@ -22,10 +22,12 @@ queue = django_rq.get_queue('default')
|
||||
queuelow = django_rq.get_queue('low')
|
||||
queuehigh = django_rq.get_queue('low')
|
||||
from rowers.utils import myqueue
|
||||
from rowers.models import C2WorldClassAgePerformance
|
||||
from rowers.models import C2WorldClassAgePerformance,Rower,Workout,TombStone
|
||||
|
||||
from django.core.exceptions import PermissionDenied
|
||||
|
||||
from rowers.utils import custom_exception_handler,NoTokenError
|
||||
|
||||
oauth_data = {
|
||||
'client_id': GARMIN_CLIENT_KEY,
|
||||
'client_secret': GARMIN_CLIENT_SECRET,
|
||||
@@ -80,3 +82,30 @@ def garmin_processcallback(redirect_response,resource_owner_key,resource_owner_s
|
||||
garminrefreshtoken = oauth_tokens.get('oauth_token_secret')
|
||||
|
||||
return garmintoken,garminrefreshtoken
|
||||
|
||||
def garmin_open(user):
|
||||
r = Rower.objects.get(user=user)
|
||||
token = Rower.garmintoken
|
||||
|
||||
if (token == '') or (token is None):
|
||||
raise NoTokenError("User has no garmin token")
|
||||
|
||||
return token
|
||||
|
||||
def get_garmin_workout_list(user):
|
||||
r = Rower.objects.get(user=user)
|
||||
if (r.garmintoken == '') or (r.stravatoken is None):
|
||||
s = "Token doesn't exist. Need to authorize"
|
||||
return custom_exception_handler(401,s)
|
||||
|
||||
garmin = OAuth1Session(oauth_data['client_id'],
|
||||
client_secret=oauth_data['client_secret'],
|
||||
resource_owner_key=r.garmintoken,
|
||||
resource_owner_secret=r.garminrefreshtoken,
|
||||
)
|
||||
|
||||
url = 'https://healthapi.garmin.com/wellness-api/rest/activities?uploadStartTimeInSeconds=1593113760&uploadEndTimeInSeconds=1593279360'
|
||||
|
||||
result = garmin.get(url)
|
||||
|
||||
return result
|
||||
|
||||
Reference in New Issue
Block a user