Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: remoting/tools/gaia_auth.py

Issue 3133014: Added hostdir.py - a simple Chromoting Directory client. (Closed)
Patch Set: - Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | remoting/tools/hostdir.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2010 The Chromium Authors. All rights reserved. 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 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import getpass 5 import getpass
6 import os 6 import os
7 import urllib 7 import urllib
8 8
9 default_gaia_url = "https://www.google.com:443/accounts/ClientLogin" 9 DEFAULT_GAIA_URL = "https://www.google.com:443/accounts/ClientLogin"
10 10
11 class GaiaAuthenticator: 11 class GaiaAuthenticator:
12 def __init__(self, service, url = default_gaia_url): 12 def __init__(self, service, url = DEFAULT_GAIA_URL):
13 self._service = service 13 self._service = service
14 self._url = url 14 self._url = url
15 15
16 ## Logins to gaia and returns auth token. 16 ## Logins to gaia and returns auth token.
17 def authenticate(self, email, passwd): 17 def authenticate(self, email, passwd):
18 params = urllib.urlencode({'Email': email, 'Passwd': passwd, 18 params = urllib.urlencode({'Email': email, 'Passwd': passwd,
19 'source': 'chromoting', 19 'source': 'chromoting',
20 'service': self._service, 20 'service': self._service,
21 'PersistentCookie': 'true', 21 'PersistentCookie': 'true',
22 'accountType': 'GOOGLE'}) 22 'accountType': 'GOOGLE'})
23 f = urllib.urlopen(self._url, params); 23 f = urllib.urlopen(self._url, params);
24 result = f.read() 24 result = f.read()
25 for line in result.splitlines(): 25 for line in result.splitlines():
26 if line.startswith('Auth='): 26 if line.startswith('Auth='):
27 auth_string = line[5:] 27 auth_string = line[5:]
28 return auth_string 28 return auth_string
29 raise Exception("Gaia didn't return auth token: " + result) 29 raise Exception("Gaia didn't return auth token: " + result)
OLDNEW
« no previous file with comments | « no previous file | remoting/tools/hostdir.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698