restore OAuth2 authentication error messages
This commit is contained in:
@@ -974,11 +974,12 @@ class DeviantartAPI():
|
|||||||
|
|
||||||
auth = (self.client_id, self.client_secret)
|
auth = (self.client_id, self.client_secret)
|
||||||
response = self.extractor.request(
|
response = self.extractor.request(
|
||||||
url, method="POST", data=data, auth=auth)
|
url, method="POST", data=data, auth=auth, fatal=False)
|
||||||
data = response.json()
|
data = response.json()
|
||||||
|
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
raise exception.AuthenticationError('"{} ({})"'.format(
|
self.log.debug("Server response: %s", data)
|
||||||
|
raise exception.AuthenticationError('"{}" ({})'.format(
|
||||||
data.get("error_description"), data.get("error")))
|
data.get("error_description"), data.get("error")))
|
||||||
if refresh_token:
|
if refresh_token:
|
||||||
_refresh_token_cache.update(refresh_token, data["refresh_token"])
|
_refresh_token_cache.update(refresh_token, data["refresh_token"])
|
||||||
|
|||||||
@@ -259,12 +259,17 @@ class RedditAPI():
|
|||||||
data = {"grant_type": ("https://oauth.reddit.com/"
|
data = {"grant_type": ("https://oauth.reddit.com/"
|
||||||
"grants/installed_client"),
|
"grants/installed_client"),
|
||||||
"device_id": "DO_NOT_TRACK_THIS_DEVICE"}
|
"device_id": "DO_NOT_TRACK_THIS_DEVICE"}
|
||||||
|
|
||||||
|
auth = (self.client_id, "")
|
||||||
response = self.extractor.request(
|
response = self.extractor.request(
|
||||||
url, method="POST", data=data, auth=(self.client_id, ""))
|
url, method="POST", data=data, auth=auth, fatal=False)
|
||||||
|
data = response.json()
|
||||||
|
|
||||||
if response.status_code != 200:
|
if response.status_code != 200:
|
||||||
raise exception.AuthenticationError('"{} ({})"'.format(
|
self.log.debug("Server response: %s", data)
|
||||||
response.json().get("message"), response.status_code))
|
raise exception.AuthenticationError('"{}: {}"'.format(
|
||||||
return "Bearer " + response.json()["access_token"]
|
data.get("error"), data.get("message")))
|
||||||
|
return "Bearer " + data["access_token"]
|
||||||
|
|
||||||
def _call(self, endpoint, params):
|
def _call(self, endpoint, params):
|
||||||
url = "https://oauth.reddit.com" + endpoint
|
url = "https://oauth.reddit.com" + endpoint
|
||||||
|
|||||||
Reference in New Issue
Block a user