ibm-cloud - 我们如何通过以下 curl 请求检索用户 ID 和 iam 令牌?
问题描述
作为联合用户,它必须使用 API 密钥或一次性密码进行身份验证。我试图执行以下 curl 请求:-
例子 :-
输入 :-
curl -s -u 'bx:bx' -k -X POST --header 'Content-Type: application/x-www-form-urlencoded' --header 'Accept: application/json' -d "grant_type=password&response_type=cloud_iam,ims_portal&username=${1}&password=${2}&ims_account=${3}" https://iam.ng.bluemix.net/oidc/token
输出 :-
"errorMessage":"You cannot authenticate with user name and password, as you are a federated user","errorDetails":"Your user id '<<><><>>' is federated and must use an API key or one-time passcode to authenticate"
但是我们如何验证用户来生成 iam_token 和 iam_user_id 呢?
解决方案
您从 SoftLayer 指南中引用的代码片段具有设置 SoftLayer 用户名和 API 密钥的结果:
echo "SL_USERNAME: $SL_USERNAME"
echo "SL_API_KEY: $SL_API_KEY"
这是一种迂回的方式来查找在您的用户配置文件中看到的作为 API 用户名和身份验证密钥列出的相同信息。如果您没有看到 API 用户名和身份验证密钥,您可以在用户列表中您的姓名旁边的操作菜单上创建一个。
然后您可以执行基础设施 API,我希望这是最终目标。
export IAAS_USERNAME=<API Username>
export IAAS_KEY=<Authentication Key>
curl -u $IAAS_USERNAME:$IAAS_KEY https://api.softlayer.com/rest/v3/SoftLayer_Account/getAllBillingItems
目前尚不清楚是否有必要围绕 IAM 代币进行讨论。如果上述建议不充分,请提供有关您要达到的目标的更多指导。
推荐阅读
- python - 特定 url 的 Django REST API 端点
- javascript - JSON.stringify 没有正确转换对象
- php - Wordpress PHP Array 如何获取值
- c++ - 继承C++为什么不调用父构造函数
- perl - 为什么没有引号的 Perl 中的 IF 条件下没有解析数字
- python - Python - 线程和 IO 访问中的无限循环
- python - 如何计算进度
- node.js - Firebase 中的 Node Express 404 错误状态代码
- vba - 更改内容控件中的文本非常慢
- reactjs - 如何在 npx create-react-app 中修复此错误?