Skip to content

Commit

Permalink
catch url shortner errors and use a key
Browse files Browse the repository at this point in the history
  • Loading branch information
jay0lee committed Mar 18, 2015
1 parent e82a2c2 commit e789f88
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions oauth2client/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -164,11 +164,14 @@ def run(flow, storage, http=None, short_url=False):
authorize_url = flow.step1_get_authorize_url()

if short_url:
from apiclient.discovery import build
service = build('urlshortener', 'v1', http=http)
url_result = service.url().insert(body={'longUrl': authorize_url}).execute()
authorize_url = url_result['id']

try:
from apiclient.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 FLAGS.auth_local_webserver:
webbrowser.open(authorize_url, new=1, autoraise=True)
print 'Your browser has been opened to visit:'
Expand Down

0 comments on commit e789f88

Please sign in to comment.