summaryrefslogtreecommitdiffstats
path: root/remoting/tools
diff options
context:
space:
mode:
authorgarykac@google.com <garykac@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 01:44:23 +0000
committergarykac@google.com <garykac@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-11 01:44:23 +0000
commit0c1195cdd9b3da27748776d109b25bfd71a22ffc (patch)
treea9027c8abfe2132f4b645cb3957d4bc43acb7afe /remoting/tools
parent85546bf0e8e7ccc43784997279ffe131628ec062 (diff)
downloadchromium_src-0c1195cdd9b3da27748776d109b25bfd71a22ffc.zip
chromium_src-0c1195cdd9b3da27748776d109b25bfd71a22ffc.tar.gz
chromium_src-0c1195cdd9b3da27748776d109b25bfd71a22ffc.tar.bz2
Extract auth token into separate .chromotingAuthToken file so it can be re-used.
Modify chromoting_simple_host to accept cmd-line args for jid and auth-token. BUG=none TEST=none Review URL: http://codereview.chromium.org/2757006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49484 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/tools')
-rwxr-xr-xremoting/tools/gettoken.py31
1 files changed, 29 insertions, 2 deletions
diff --git a/remoting/tools/gettoken.py b/remoting/tools/gettoken.py
index 853d09b..31db75b 100755
--- a/remoting/tools/gettoken.py
+++ b/remoting/tools/gettoken.py
@@ -7,9 +7,12 @@
# gettoken.py can be used to get auth token from Gaia. It asks username and
# password and then prints token on the screen.
-import urllib
import getpass
+import os
+import urllib
+
url = "https://www.google.com:443/accounts/ClientLogin"
+auth_filename = '.chromotingAuthToken'
print "Email:",
email = raw_input()
@@ -20,4 +23,28 @@ params = urllib.urlencode({'Email': email, 'Passwd': passwd,
'source': 'chromoting', 'service': 'chromiumsync',
'PersistentCookie': 'true', 'accountType': 'GOOGLE'})
f = urllib.urlopen(url, params);
-print f.read()
+
+auth_found = False
+for line in f:
+ if line.startswith('Auth='):
+ auth_string = line[5:]
+
+ # Set permission mask for created file.
+ os.umask(0066)
+ auth_file = open(auth_filename, 'w')
+ auth_file.write(email)
+ auth_file.write('\n')
+ auth_file.write(auth_string)
+ auth_file.close()
+
+ print
+ print 'Auth token:'
+ print
+ print auth_string
+ print '...saved in', auth_filename
+ auth_found = True
+
+if not auth_found:
+ print 'ERROR - Unable to find Auth token in output:'
+ for line in f:
+ print line,