From 04f4f9badb630b9cca323c5a5e1575da8c7b242d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sat, 5 Jun 2021 14:28:26 +0200 Subject: [PATCH] [oauth] prevent exceptions when reporting errors (#1603) --- gallery_dl/extractor/oauth.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gallery_dl/extractor/oauth.py b/gallery_dl/extractor/oauth.py index 483c657030..c798ad0037 100644 --- a/gallery_dl/extractor/oauth.py +++ b/gallery_dl/extractor/oauth.py @@ -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""" @@ -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 = { @@ -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("_", "-")