本文整理匯總了Python中cloudmesh_client.common.ConfigDict.ConfigDict.data["cloudmesh"]["comet"]["auth_provider"]方法的典型用法代碼示例。如果您正苦於以下問題:Python ConfigDict.data["cloudmesh"]["comet"]["auth_provider"]方法的具體用法?Python ConfigDict.data["cloudmesh"]["comet"]["auth_provider"]怎麽用?Python ConfigDict.data["cloudmesh"]["comet"]["auth_provider"]使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類cloudmesh_client.common.ConfigDict.ConfigDict
的用法示例。
在下文中一共展示了ConfigDict.data["cloudmesh"]["comet"]["auth_provider"]方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: get_apikey
# 需要導入模塊: from cloudmesh_client.common.ConfigDict import ConfigDict [as 別名]
# 或者: from cloudmesh_client.common.ConfigDict.ConfigDict import data["cloudmesh"]["comet"]["auth_provider"] [as 別名]
def get_apikey():
user = raw_input("Comet Nucleus Usename: ")
password = getpass.getpass()
keyurl = "https://comet-nucleus.sdsc.edu/nucleus/getkey"
headers = {"ACCEPT": "application/json"}
r = requests.get(keyurl, headers=headers, auth=HTTPBasicAuth(user, password))
if r.status_code == 200:
keyobj = r.json()
api_key = keyobj["key_name"]
api_secret = keyobj["key"]
config = ConfigDict("cloudmesh.yaml")
config.data["cloudmesh"]["comet"]["auth_provider"] = 'apikey'
config.data["cloudmesh"]["comet"]["apikey"]["api_key"] = api_key
config.data["cloudmesh"]["comet"]["apikey"]["api_secret"] = api_secret
config.save()
Console.ok("api key retrieval and set was successful!")
else:
Console.error("Error getting api key. " \
"Please check your username/password", traceflag=False)