Bluemix API检索服务凭证 [英] Bluemix API to retrieve the service credentials
本文介绍了Bluemix API检索服务凭证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在以前的问题,我可以获得与MessageHub管理api进行交互的apiKey。
In a previous question, I can get the apiKey for interacting with the MessageHub management api.
我没有将此服务绑定到Bluemix应用程序,所以我没有无法访问我的应用程序中的VCAP_SERVICES环境变量。
I'm not binding to this service to a Bluemix application, so I don't have access to the VCAP_SERVICES environment variable in my application.
我想以编程方式获取服务凭证。我认为这可能是通用的Bluemix cf api问题,而不是MessageHub问题。
I would like to retreive the service credentials programatically. I think this may be a generic Bluemix cf api question rather than a MessageHub question.
如何使用API调用检索服务凭证?
How can I retrieve the service credentials using an API call?
推荐答案
使用 cf-python-client 库:
from cloudfoundry_client.client import CloudFoundryClient
target_endpoint = 'https://api.ng.bluemix.net'
client = CloudFoundryClient(target_endpoint, skip_verification=False)
client.init_with_user_credentials(
ibm_id,
ibm_id_password
)
mh_service_instance = client.service_instances.get_first(name='my_service')
if mh_service_instance:
mh_service_instance_id = mh_service_instance['metadata']['guid']
print(mh_service_instance_id)
print(list(mh_service_instance.service_keys()))
这篇关于Bluemix API检索服务凭证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文