diff --git a/trakt/api.py b/trakt/api.py index 3c09cab..6ce7960 100644 --- a/trakt/api.py +++ b/trakt/api.py @@ -10,7 +10,8 @@ from trakt import errors from trakt.config import AuthConfig from trakt.core import TIMEOUT -from trakt.errors import BadRequestException, BadResponseException, OAuthException +from trakt.errors import (BadRequestException, BadResponseException, + OAuthException) __author__ = 'Elan Ruusamäe' @@ -256,8 +257,9 @@ def refresh_token(self): except (OAuthException, BadRequestException) as e: if e.response is not None: try: - error = e.response.json().get("error") - error_description = e.response.json().get("error_description") + data = e.response.json() + error = data.get("error") + error_description = data.get("error_description") except JSONDecodeError: error = "Invalid JSON response" error_description = e.response.text