summaryrefslogtreecommitdiffstats
path: root/remoting/tools/gaia_auth.py
diff options
context:
space:
mode:
authorsergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-17 23:43:00 +0000
committersergeyu@chromium.org <sergeyu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-17 23:43:00 +0000
commit7620735be42ebc236d2da42d64f22dc5dedd01f9 (patch)
treebaf0e6311b84830cd76df764e73e9aacfeb65e3e /remoting/tools/gaia_auth.py
parentf90ab58c11abf783c850c632f9b0467f968e4045 (diff)
downloadchromium_src-7620735be42ebc236d2da42d64f22dc5dedd01f9.zip
chromium_src-7620735be42ebc236d2da42d64f22dc5dedd01f9.tar.gz
chromium_src-7620735be42ebc236d2da42d64f22dc5dedd01f9.tar.bz2
JSON based host config storage implemented. Python script for host registration.
BUG=None TEST=None Review URL: http://codereview.chromium.org/2804007 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50166 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'remoting/tools/gaia_auth.py')
-rw-r--r--remoting/tools/gaia_auth.py29
1 files changed, 29 insertions, 0 deletions
diff --git a/remoting/tools/gaia_auth.py b/remoting/tools/gaia_auth.py
new file mode 100644
index 0000000..da364e0
--- /dev/null
+++ b/remoting/tools/gaia_auth.py
@@ -0,0 +1,29 @@
+# Copyright (c) 2010 The Chromium Authors. All rights reserved.
+# Use of this source code is governed by a BSD-style license that can be
+# found in the LICENSE file.
+
+import getpass
+import os
+import urllib
+
+default_gaia_url = "https://www.google.com:443/accounts/ClientLogin"
+
+class GaiaAuthenticator:
+ def __init__(self, service, url = default_gaia_url):
+ self._service = service
+ self._url = url
+
+ ## Logins to gaia and returns auth token.
+ def authenticate(self, email, passwd):
+ params = urllib.urlencode({'Email': email, 'Passwd': passwd,
+ 'source': 'chromoting',
+ 'service': self._service,
+ 'PersistentCookie': 'true',
+ 'accountType': 'GOOGLE'})
+ f = urllib.urlopen(self._url, params);
+ result = f.read()
+ for line in result.splitlines():
+ if line.startswith('Auth='):
+ auth_string = line[5:]
+ return auth_string
+ raise Exception("Gaia didn't return auth token: " + result)