OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2010 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 # | 6 # |
7 # gettoken.py can be used to get auth token from Gaia. It asks username and | 7 # gettoken.py can be used to get auth token from Gaia. It asks username and |
8 # password and then prints token on the screen. | 8 # password and then prints token on the screen. |
9 | 9 |
10 import getpass | 10 import getpass |
11 import os | 11 import os |
12 import urllib | 12 import urllib |
13 | 13 |
14 import gaia_auth | 14 import gaia_auth |
15 | 15 |
16 auth_filepath = os.path.join(os.path.expanduser('~'), '.chromotingAuthToken') | 16 chromoting_auth_filepath = os.path.join(os.path.expanduser('~'), |
| 17 '.chromotingAuthToken') |
| 18 chromoting_dir_auth_filepath = os.path.join(os.path.expanduser('~'), |
| 19 '.chromotingDirectoryAuthToken') |
17 | 20 |
18 print "Email:", | 21 print "Email:", |
19 email = raw_input() | 22 email = raw_input() |
20 | 23 |
21 passwd = getpass.getpass("Password: ") | 24 passwd = getpass.getpass("Password: ") |
22 | 25 |
23 authenticator = gaia_auth.GaiaAuthenticator('chromiumsync'); | 26 chromoting_authenticator = gaia_auth.GaiaAuthenticator('chromiumsync'); |
24 auth_token = authenticator.authenticate(email, passwd) | 27 chromoting_auth_token = chromoting_authenticator.authenticate(email, passwd) |
25 | 28 |
26 # Set permission mask for created file. | 29 chromoting_dir_authenticator = gaia_auth.GaiaAuthenticator('chromoting'); |
| 30 chromoting_dir_auth_token = \ |
| 31 chromoting_dir_authenticator.authenticate(email, passwd) |
| 32 |
| 33 # Set permission mask for created files. |
27 os.umask(0066) | 34 os.umask(0066) |
28 auth_file = open(auth_filepath, 'w') | 35 |
29 auth_file.write(email) | 36 chromoting_auth_file = open(chromoting_auth_filepath, 'w') |
30 auth_file.write('\n') | 37 chromoting_auth_file.write(email) |
31 auth_file.write(auth_token) | 38 chromoting_auth_file.write('\n') |
32 auth_file.close() | 39 chromoting_auth_file.write(chromoting_auth_token) |
| 40 chromoting_auth_file.close() |
33 | 41 |
34 print | 42 print |
35 print 'Auth token:' | 43 print 'Chromoting (sync) Auth Token:' |
36 print | 44 print |
37 print auth_token | 45 print chromoting_auth_token |
38 print '...saved in', auth_filepath | 46 print '...saved in', chromoting_auth_filepath |
| 47 |
| 48 chromoting_dir_auth_file = open(chromoting_dir_auth_filepath, 'w') |
| 49 chromoting_dir_auth_file.write(email) |
| 50 chromoting_dir_auth_file.write('\n') |
| 51 chromoting_dir_auth_file.write(chromoting_dir_auth_token) |
| 52 chromoting_dir_auth_file.close() |
| 53 |
| 54 print |
| 55 print 'Chromoting Directory Auth Token:' |
| 56 print |
| 57 print chromoting_dir_auth_token |
| 58 print '...saved in', chromoting_dir_auth_filepath |
OLD | NEW |