1 # Copyright (c) 2010 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
9 DEFAULT_GAIA_URL
= "https://www.google.com:443/accounts/ClientLogin"
11 class GaiaAuthenticator
:
12 def __init__(self
, service
, url
= DEFAULT_GAIA_URL
):
13 self
._service
= service
16 ## Logins to gaia and returns auth token.
17 def authenticate(self
, email
, passwd
):
18 params
= urllib
.urlencode({'Email': email
, 'Passwd': passwd
,
19 'source': 'chromoting',
20 'service': self
._service
,
21 'PersistentCookie': 'true',
22 'accountType': 'GOOGLE'})
23 f
= urllib
.urlopen(self
._url
, params
);
25 for line
in result
.splitlines():
26 if line
.startswith('Auth='):
27 auth_string
= line
[5:]
29 raise Exception("Gaia didn't return auth token: " + result
)