Skip to content

Commit 6ef9d4f

Browse files
committed
Make sure token expires_in values are integers
Closes #237
1 parent 1686f09 commit 6ef9d4f

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

emailproxy.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
__author__ = 'Simon Robinson'
77
__copyright__ = 'Copyright (c) 2024 Simon Robinson'
88
__license__ = 'Apache 2.0'
9-
__version__ = '2024-03-14' # ISO 8601 (YYYY-MM-DD)
9+
__version__ = '2024-03-15' # ISO 8601 (YYYY-MM-DD)
1010
__package_version__ = '.'.join([str(int(i)) for i in __version__.split('-')]) # for pyproject.toml usage only
1111

1212
import abc
@@ -1114,7 +1114,11 @@ def refresh_oauth2_access_token(token_url, client_id, client_secret, refresh_tok
11141114
response = urllib.request.urlopen(
11151115
urllib.request.Request(token_url, data=urllib.parse.urlencode(params).encode('utf-8'),
11161116
headers={'User-Agent': APP_NAME}), timeout=AUTHENTICATION_TIMEOUT).read()
1117-
return json.loads(response)
1117+
token = json.loads(response)
1118+
if 'expires_in' in token: # some servers return integer values as strings - fix expiry values (GitHub #237)
1119+
token['expires_in'] = int(token['expires_in'])
1120+
return token
1121+
11181122
except urllib.error.HTTPError as e:
11191123
e.message = json.loads(e.read())
11201124
Log.debug('Error refreshing access token - received invalid response:', e.message)

0 commit comments

Comments
 (0)