Skip to content

Commit

Permalink
[oauth] prevent exceptions when reporting errors (#1603)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Jun 5, 2021
1 parent dfe1e09 commit 04f4f9b
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions gallery_dl/extractor/oauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ def open(self, url, params, recv=None):
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"""
Expand Down Expand Up @@ -135,8 +138,7 @@ def _oauth2_authorization_code_grant(
))
return
if "error" in params:
self.send(params["error"])
return
return self.error(params)

# exchange the authorization code for a token
data = {
Expand All @@ -156,8 +158,7 @@ def _oauth2_authorization_code_grant(

# check token response
if "error" in data:
self.send(data["error"])
return
return self.error(data)

token = data[key]
token_name = key.replace("_", "-")
Expand Down

0 comments on commit 04f4f9b

Please sign in to comment.