From 2bc6c8bca059288ed0faa72a22f2cc3c9083825b Mon Sep 17 00:00:00 2001 From: Jay Lee Date: Tue, 13 Aug 2019 08:35:06 -0400 Subject: [PATCH] 200 or bust for URL shorten --- src/gam.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gam.py b/src/gam.py index f11be94b..cad892b8 100755 --- a/src/gam.py +++ b/src/gam.py @@ -7613,9 +7613,11 @@ class ShortURLFlow(google_auth_oauthlib.flow.InstalledAppFlow): url_shortnr = 'https://gam-shortn.appspot.com/create' headers = {'Content-Type': 'application/json'} try: - _, content = simplehttp.request(url_shortnr, 'POST', '{"long_url": "%s"}' % long_url, headers=headers) + resp, content = simplehttp.request(url_shortnr, 'POST', '{"long_url": "%s"}' % long_url, headers=headers) except: return long_url, state + if resp.status != 200: + return long_url, state return json.loads(content).get('short_url', ''), state def _run_oauth_flow(client_id, client_secret, scopes, access_type, login_hint=None):