[oauth] prevent exceptions when reporting errors (#1603)

This commit is contained in:
Mike Fährmann 2021-06-05 14:28:26 +02:00
parent dfe1e09df0
commit 04f4f9badb
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -73,6 +73,9 @@ class OAuthBase(Extractor):
print(url, end="\n\n", flush=True)
return (recv or self.recv)()
def error(self, msg):
return self.send("Remote server reported an error:\n\n" + str(msg))
def _oauth1_authorization_flow(
self, request_token_url, authorize_url, access_token_url):
"""Perform the OAuth 1.0a authorization flow"""
@ -135,8 +138,7 @@ class OAuthBase(Extractor):
))
return
if "error" in params:
self.send(params["error"])
return
return self.error(params)
# exchange the authorization code for a token
data = {
@ -156,8 +158,7 @@ class OAuthBase(Extractor):
# check token response
if "error" in data:
self.send(data["error"])
return
return self.error(data)
token = data[key]
token_name = key.replace("_", "-")