Merge branch 'release/v18.10.8'
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
from abc import ABCMeta, ABC, abstractmethod
|
from abc import ABCMeta, ABC, abstractmethod
|
||||||
from importlib import import_module
|
from importlib import import_module
|
||||||
from rowers.models import Rower, User
|
from rowers.models import Rower, User
|
||||||
from rowers.utils import NoTokenError
|
from rowers.utils import NoTokenError,dologging
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
@@ -85,6 +85,7 @@ class SyncIntegration(metaclass=ABCMeta):
|
|||||||
|
|
||||||
@abstractmethod
|
@abstractmethod
|
||||||
def get_token(self, code, *args, **kwargs) -> (str, int, str):
|
def get_token(self, code, *args, **kwargs) -> (str, int, str):
|
||||||
|
logfile = kwargs.get('logfile',None)
|
||||||
redirect_uri = self.oauth_data['redirect_uri']
|
redirect_uri = self.oauth_data['redirect_uri']
|
||||||
client_secret = self.oauth_data['client_secret']
|
client_secret = self.oauth_data['client_secret']
|
||||||
client_id = self.oauth_data['client_id']
|
client_id = self.oauth_data['client_id']
|
||||||
@@ -127,6 +128,9 @@ class SyncIntegration(metaclass=ABCMeta):
|
|||||||
try:
|
try:
|
||||||
thetoken = token_json['access_token']
|
thetoken = token_json['access_token']
|
||||||
except KeyError: # pragma: no cover
|
except KeyError: # pragma: no cover
|
||||||
|
if logfile:
|
||||||
|
s = json.dumps(token_json)
|
||||||
|
dologging(logfile,s)
|
||||||
raise NoTokenError("Failed to obtain token")
|
raise NoTokenError("Failed to obtain token")
|
||||||
try:
|
try:
|
||||||
refresh_token = token_json['refresh_token']
|
refresh_token = token_json['refresh_token']
|
||||||
@@ -145,6 +149,8 @@ class SyncIntegration(metaclass=ABCMeta):
|
|||||||
except (ValueError, TypeError): # pragma: no cover
|
except (ValueError, TypeError): # pragma: no cover
|
||||||
expires_in = 0
|
expires_in = 0
|
||||||
else: # pragma: no cover
|
else: # pragma: no cover
|
||||||
|
if logfile:
|
||||||
|
dologging(logfile,response.text)
|
||||||
raise NoTokenError("Failed to obtain token")
|
raise NoTokenError("Failed to obtain token")
|
||||||
|
|
||||||
return [thetoken, expires_in, refresh_token]
|
return [thetoken, expires_in, refresh_token]
|
||||||
|
|||||||
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
BIN
rowers/tests/testdata/testdata.tcx.gz
vendored
Binary file not shown.
@@ -455,7 +455,14 @@ def rower_process_stravacallback(request):
|
|||||||
|
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
res = strava_integration.get_token(code)
|
try:
|
||||||
|
res = strava_integration.get_token(code,logfile='strava_log.log')
|
||||||
|
except NoTokenError:
|
||||||
|
message = "Something went wrong with the Strava authorization"
|
||||||
|
messages.error(request, message)
|
||||||
|
url = reverse('rower_exportsettings_view')
|
||||||
|
|
||||||
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
if res[0]:
|
if res[0]:
|
||||||
access_token = res[0]
|
access_token = res[0]
|
||||||
@@ -481,7 +488,7 @@ def rower_process_stravacallback(request):
|
|||||||
messages.error(request, message)
|
messages.error(request, message)
|
||||||
url = reverse('rower_exportsettings_view')
|
url = reverse('rower_exportsettings_view')
|
||||||
|
|
||||||
return HttpResponseRedirect(url)
|
return HttpResponseRedirect(url)
|
||||||
|
|
||||||
|
|
||||||
# Process SportTracks callback
|
# Process SportTracks callback
|
||||||
|
|||||||
Reference in New Issue
Block a user