Use webbrowser.open to launch browser from oauth2client.tools.
Fixes issue #84.
Reviewed in http://codereview.appspot.com/5542046/.
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 gflags
import socket
import sys
+import webbrowser
from client import FlowExchangeError
@@ -120,13 +121,21 @@
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