How to generate an IBM Cloud token from an API Key

蹲街弑〆低调 提交于 2020-04-18 04:42:05

问题


I have generated an API key for IBM Cloud, how do I programmatically generate a token from the API key?


回答1:


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'

Replace xxx with your API key.

The basic authorization is base64 encoded with a username of bx and a password of bx.

The response looks like the following:

{
    "access_token": "bearer token",
    "refresh_token": "refresh token",
    "token_type": "Bearer",
    "expires_in": 3600,
    "expiration": 1581031424,
    "scope": "ibm openid"
}


来源:https://stackoverflow.com/questions/60104517/how-to-generate-an-ibm-cloud-token-from-an-api-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!