From 921c6c1cb885eb4f64fab61906f81bebc4e5327d Mon Sep 17 00:00:00 2001 From: aszlig Date: Mon, 10 Jun 2019 23:55:49 +0200 Subject: fetch-gog: Provide a better login failure message So far if the login credentials were wrong, you get something like this: Traceback (most recent call last): File "/nix/store/...-fetch-gog.py", line 113, in GogFetcher(sys.argv[1], sys.argv[2], sys.argv[3]).fetch() File "/nix/store/...-fetch-gog.py", line 15, in __init__ self.login() File "/nix/store/...-fetch-gog.py", line 28, in login auth_code = parse_qs(urlsplit(browser.get_url()).query)['code'] KeyError: 'code' This is isn't very helpful and might hint that there is something wrong with the fetcher. Of course, if GOG would change their login interface and no longer expose the "code" query string item, it might still say login failure, but right now we don't have a better way to detect it. At least if we get a login failure with a login that has been working so far, we know something has changed upstream :-) Signed-off-by: aszlig Reported-by: @Profpatsch --- pkgs/games/gog/fetch-gog/default.nix | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'pkgs/games/gog') diff --git a/pkgs/games/gog/fetch-gog/default.nix b/pkgs/games/gog/fetch-gog/default.nix index b49f0dab..31b4cd38 100644 --- a/pkgs/games/gog/fetch-gog/default.nix +++ b/pkgs/games/gog/fetch-gog/default.nix @@ -185,13 +185,19 @@ let browser['login[password]'] = ${mkPyStr password} browser.submit_selected() - auth_code = parse_qs(urlsplit(browser.get_url()).query)['code'] + query = parse_qs(urlsplit(browser.get_url()).query) + + if 'code' not in query: + sys.stderr.write( + "Unable to login with the provided GOG credentials." + ) + raise SystemExit(1) token_url = "https://auth.gog.com/token?" + urlencode({ 'client_id': ${mkPyStr clientId}, 'client_secret': ${mkPyStr clientSecret}, 'grant_type': 'authorization_code', - 'code': auth_code, + 'code': query['code'], 'redirect_uri': ${mkPyStr redirectUri} }) -- cgit 1.4.1