improve error message for OAuth2 authentication

This commit is contained in:
Mike Fährmann
2018-08-11 23:54:25 +02:00
parent 7f4e41c989
commit 4313c95bc9
3 changed files with 10 additions and 8 deletions

View File

@@ -561,10 +561,11 @@ class DeviantartAPI():
auth = (self.client_id, self.client_secret)
response = self.session.post(url, data=data, auth=auth)
if response.status_code != 200:
raise exception.AuthenticationError()
data = response.json()
if response.status_code != 200:
raise exception.AuthenticationError('"{} ({})"'.format(
data.get("error_description"), data.get("error")))
if refresh_token:
_refresh_token_cache.invalidate(refresh_token)
_refresh_token_cache(refresh_token, data["refresh_token"])