From: Calin Crisan Date: Sun, 22 Nov 2015 19:22:14 +0000 (+0200) Subject: gdrive upload: fixed oauth access token renewal X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=42b7dc91cde181e7f023eaaa76c3ac8cf50ab91c;p=motioneye-debian gdrive upload: fixed oauth access token renewal --- diff --git a/motioneye/__init__.py b/motioneye/__init__.py index 47b4500..b9cb08a 100644 --- a/motioneye/__init__.py +++ b/motioneye/__init__.py @@ -1,2 +1,2 @@ -VERSION = "0.28.3" +VERSION = "0.28.4-git" diff --git a/motioneye/uploadservices.py b/motioneye/uploadservices.py index 2e427ca..3f520d4 100644 --- a/motioneye/uploadservices.py +++ b/motioneye/uploadservices.py @@ -221,7 +221,7 @@ class GoogleDrive(UploadService): return items[0]['id'] - def _request(self, url, body=None, headers=None): + def _request(self, url, body=None, headers=None, retry_auth=True): if not self._authorization_key: msg = 'missing authorization key' self.error(msg) @@ -247,11 +247,12 @@ class GoogleDrive(UploadService): response = urllib2.urlopen(request) except urllib2.HTTPError as e: - if e.code == 403: # unauthorized, access token may have expired + if e.code == 401 and retry_auth: # unauthorized, access token may have expired try: - self.debug('access token might have expired, refreshing it') + self.debug('access token has probably expired, refreshing it') self._credentials.refresh(httplib2.Http()) save() + self._request(url, body, headers, retry_auth=False) except Exception as e: self.error('refreshing access token failed')