Package u1rest :: Module createfilekeystore
[hide private]
[frames] | no frames]

Source Code for Module u1rest.createfilekeystore

 1  #!/usr/bin/python 
 2  #Copyright (C) 2011 by John O'Brien 
 3  # 
 4  #Permission is hereby granted, free of charge, to any person obtaining a copy 
 5  #of this software and associated documentation files (the "Software"), to deal 
 6  #in the Software without restriction, including without limitation the rights 
 7  #to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
 8  #copies of the Software, and to permit persons to whom the Software is 
 9  #furnished to do so, subject to the following conditions: 
10  # 
11  #The above copyright notice and this permission notice shall be included in 
12  #all copies or substantial portions of the Software. 
13  # 
14  #THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
15  #IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
16  #FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
17  #AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 
18  #LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 
19  #OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 
20  #THE SOFTWARE. 
21  """Use this to create a file to store credentials. 
22   
23  This is used instead of using the credentials stored in the Gnome Keyring. 
24  You must already have an Ubuntu One subscription before you do this. 
25  """ 
26   
27  from optparse import OptionParser 
28  from u1rest.lib.auth.simpleauth import FileStoreAuthenticator 
29   
30 -def create_credential_file():
31 """Create the credential file.""" 32 op_parser = OptionParser() 33 op_parser.add_option("--email", dest="email", 34 help="The SSO Email Address for the user.") 35 op_parser.add_option("--password", dest="password", 36 help="The SSO Password for the user.") 37 op_parser.add_option("--name", dest="name", 38 help="The Token Name for the client's OAuth token.") 39 (options, _) = op_parser.parse_args() 40 auth_store = FileStoreAuthenticator() 41 auth_store.create_and_save_credentials( 42 options.name, options.email, options.password)
43 44 if __name__ == '__main__': 45 create_credential_file() 46