short URLs fix back

This commit is contained in:
Jay Lee
2017-01-24 14:48:44 -05:00
parent 281786b3b9
commit e2cf769b20

View File

@@ -217,6 +217,16 @@ def run_flow(flow, storage, flags=None, http=None):
flow.redirect_uri = oauth_callback
authorize_url = flow.step1_get_authorize_url()
if flags.short_url:
try:
from googleapiclient.discovery import build
service = build('urlshortener', 'v1', http=http)
url_result = service.url().insert(body={'longUrl': authorize_url},
key=u'AIzaSyBlmgbii8QfJSYmC9VTMOfqrAt5Vj5wtzE').execute()
authorize_url = url_result['id']
except:
pass
if not flags.noauth_local_webserver:
import webbrowser
webbrowser.open(authorize_url, new=1, autoraise=True)