200 or bust for URL shorten

This commit is contained in:
Jay Lee
2019-08-13 08:35:06 -04:00
parent fc1e81a01d
commit 2bc6c8bca0

View File

@@ -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):