diff options
-rw-r--r-- | remoting/host/simple_host_process.cc | 43 | ||||
-rwxr-xr-x | remoting/tools/gettoken.py | 31 |
2 files changed, 64 insertions, 10 deletions
diff --git a/remoting/host/simple_host_process.cc b/remoting/host/simple_host_process.cc index d7f454c..79db106 100644 --- a/remoting/host/simple_host_process.cc +++ b/remoting/host/simple_host_process.cc @@ -70,19 +70,46 @@ void SetConsoleEcho(bool on) { int main(int argc, char** argv) { base::AtExitManager exit_manager; + std::string username; + std::string auth_token; + // Check the argument to see if we should use a fake capturer and encoder. bool fake = false; - if (argc > 1 && std::string(argv[1]) == "--fake") { - fake = true; + // True if the JID was specified on the command line. + bool has_jid = false; + // True if the auth token was specified on the command line. + bool has_auth = false; + + for (int i = 1; i < argc; i++) { + std::string arg = argv[i]; + if (arg == "--fake") { + fake = true; + } else if (arg == "--jid") { + if (++i >= argc) { + std::cerr << "Expected JID to follow --jid option" << std::endl; + return 1; + } + has_jid = true; + username = argv[i]; + } else if (arg == "--auth") { + if (++i >= argc) { + std::cerr << "Expected auth token to follow --auth option" << std::endl; + return 1; + } + has_auth = true; + auth_token = argv[i]; + } } // Prompt user for username and auth token. - std::string username; - std::cout << "JID: "; - std::cin >> username; - std::string auth_token; - std::cout << "Auth Token: "; - std::cin >> auth_token; + if (!has_jid) { + std::cout << "JID: "; + std::cin >> username; + } + if (!has_auth) { + std::cout << "Auth Token: "; + std::cin >> auth_token; + } scoped_ptr<remoting::Capturer> capturer; scoped_ptr<remoting::Encoder> encoder; 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, |