如何从API密钥生成IBM Cloud令牌 [英] How to generate an IBM Cloud token from an API Key
本文介绍了如何从API密钥生成IBM Cloud令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经为IBM Cloud生成了API密钥,如何以编程方式从API密钥生成令牌?
I have generated an API key for IBM Cloud, how do I programmatically generate a token from the API key?
推荐答案
以下是执行此操作的curl请求.
Here is a curl request to do that.
curl --location --request POST 'https://iam.cloud.ibm.com/identity/token' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--header 'Authorization: Basic Yng6Yng=' \
--data-urlencode 'apikey=xxx' \
--data-urlencode 'response_type=cloud_iam' \
--data-urlencode 'grant_type=urn:ibm:params:oauth:grant-type:apikey'
用您的API密钥替换xxx
.
Replace xxx
with your API key.
基本授权是使用用户名bx
和密码bx
的base64编码的.
The basic authorization is base64 encoded with a username of bx
and a password of bx
.
响应如下所示:
{
"access_token": "bearer token",
"refresh_token": "refresh token",
"token_type": "Bearer",
"expires_in": 3600,
"expiration": 1581031424,
"scope": "ibm openid"
}
这篇关于如何从API密钥生成IBM Cloud令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文