我已经为IBM Cloud生成了API密钥,如何以编程方式从API密钥生成令牌?
答案 0 :(得分:3)
这是一个卷曲请求。
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
。
基本授权是使用用户名bx
和密码bx
进行编码的base64。
响应如下所示:
{
"access_token": "bearer token",
"refresh_token": "refresh token",
"token_type": "Bearer",
"expires_in": 3600,
"expiration": 1581031424,
"scope": "ibm openid"
}