Private
Public Access
1
0

Garmin auth working

This commit is contained in:
Sander Roosendaal
2020-06-28 12:26:13 +02:00
parent 7b2ffad5ab
commit c53d96d8bb
8 changed files with 11 additions and 4 deletions

View File

@@ -56,9 +56,9 @@ def garmin_authorize():
resource_owner_secret = fetch_response.get('oauth_token_secret')
authorization_url = garmin.authorization_url(base_uri)
return authorization_url
return authorization_url,resource_owner_key,resource_owner_secret
def garmin_processcallback(redirect_respones):
def garmin_processcallback(redirect_response,resource_owner_key,resource_owner_secret):
garmin = OAuth1Session(oauth_data['client_id'],
client_secret=oauth_data['client_secret'],
)

View File

@@ -34,6 +34,8 @@ The auto import and export settings only work on <a href="/rowers/paidplans/">a
alt="connect with Polar" width="130"></a></p>
<p><a href="/rowers/me/tpauthorize/"><img src="/static/img/TP_logo_horz_2_color.png"
alt="connect with Polar" width="130"></a></p>
<p><a href="/rowers/me/garminauthorize"><img src="/static/img/garmin_badge_130.png"
alt="connect with Garmin" with="130"></a></p>

View File

@@ -404,7 +404,9 @@ def rower_c2_authorize(request):
# Garmin authorization
@login_required()
def rower_garmin_authorize(request):
authorization_url = garmin_stuff.garmin_authorize()
authorization_url,token,secret = garmin_stuff.garmin_authorize()
request.session['garmin_owner_key'] = token
request.session['garmin_owner_secret'] = secret
return HttpResponseRedirect(authorization_url)
# Strava Authorization
@@ -716,7 +718,10 @@ def rower_process_polarcallback(request):
def rower_process_garmincallback(request):
r = getrower(request.user)
absoluteurl = request.build_absolute_uri()
garmintoken,garminrefreshtoken = garmin_stuff.garmin_processcallback(absoluteurl)
key = request.session['garmin_owner_key']
secret = request.session['garmin_owner_secret']
garmintoken,garminrefreshtoken = garmin_stuff.garmin_processcallback(absoluteurl,key,secret)
r.garmintoken = garmintoken
r.garminrefreshtoken = garminrefreshtoken
r.save()

Binary file not shown.

After

Width:  |  Height:  |  Size: 262 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB