From 2fdd29521b271aa022c83ffa6e18ff6a7680b5ab Mon Sep 17 00:00:00 2001 From: Joe Gregorio Date: Tue, 17 Jan 2012 09:03:28 -0500 Subject: [PATCH] Use webbrowser.open to launch browser from oauth2client.tools. Fixes issue #84. Reviewed in http://codereview.appspot.com/5542046/. --- oauth2client/tools.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/oauth2client/tools.py b/oauth2client/tools.py index 574a747..d441cd9 100644 --- a/oauth2client/tools.py +++ b/oauth2client/tools.py @@ -27,6 +27,7 @@ import BaseHTTPServer import gflags import socket import sys +import webbrowser from client import FlowExchangeError @@ -120,13 +121,21 @@ def run(flow, storage): oauth_callback = 'oob' authorize_url = flow.step1_get_authorize_url(oauth_callback) - print 'Go to the following link in your browser:' - print authorize_url - print if FLAGS.auth_local_webserver: + webbrowser.open(authorize_url, new=1, autoraise=True) + print 'Your browser has been opened to visit:' + print + print ' ' + authorize_url + print print 'If your browser is on a different machine then exit and re-run this' print 'application with the command-line parameter ' - print '--noauth_local_webserver.' + print + print ' --noauth_local_webserver' + print + else: + print 'Go to the following link in your browser:' + print + print ' ' + authorize_url print code = None