统一身份认证服务 IAM-获取IAM用户Token(使用密码):响应示例

时间:2024-08-21 15:43:13

响应示例

状态码为 201 时:

创建成功。

  • 获取 IAM 用户名为“IAMUser”,IAM用户密码为“IAMPassword”,所属账号名为“IAMDomain”,作用范围为项目“cn-north-1”,且返回的响应体中将不显示catalog信息的Token。
    响应Header参数(获取到的Token):
    X-Subject-Token:MIIatAYJKoZIhvcNAQcCoIIapTCCGqECAQExDTALB...
    响应Body参数:
    {
        "token": {
            "catalog": [],
            "expires_at": "2020-01-04T09:05:22.701000Z",
            "issued_at": "2020-01-03T09:05:22.701000Z",
            "methods": [
                "password"
            ],
            "project": {
                "domain": {
                    "id": "d78cbac186b744899480f25bd022f...",
                    "name": "IAMDomain"
                },
                "id": "aa2d97d7e62c4b7da3ffdfc11551f...",
                "name": "cn-north-1"
            },
            "roles": [
                {
                    "id": "0",
                    "name": "te_admin"
                },
                {
                    "id": "0",
                    "name": "op_gated_Video_Campus"
                }
            ],
            "user": {
                "domain": {
                    "id": "d78cbac186b744899480f25bd022f...",
                    "name": "IAMDomain"
                },
                "id": "7116d09f88fa41908676fdd4b039e...",
                "name": "IAMUser",
                "password_expires_at": ""
            }
        }
    }
  • 获取IAM用户名为“IAMUser”,IAM用户密码为“IAMPassword”,所属账号名为“IAMDomain”,作用范围为整个账号的Token。
    响应Header参数(获取到的Token):
    X-Subject-Token:MIIatAYJKoZIhvcNAQcCoIIapTCCGqECAQExDTALB...
    响应Body参数:
    {
        "token": {
            "catalog": [
                {
                    "endpoints": [
                        {
                            "id": "33e1cbdd86d34e89a63cf8ad16a5f...",
                            "interface": "public",
                            "region": "*",
                            "region_id": "*",
                            "url": "https://iam.myhuaweicloud.com/v3.0"
                        }
                    ],
                    "id": "100a6a3477f1495286579b819d399...",
                    "name": "iam",
                    "type": "iam"
                },
                {
                    "endpoints": [
                        {
                            "id": "29319cf2052d4e94bcf438b55d143...",
                            "interface": "public",
                            "region": "*",
                            "region_id": "*",
                            "url": "https://bss.sample.domain.com/v1.0"
                        }
                    ],
                    "id": "c6db69fabbd549908adcb861c7e47...",
                    "name": "bssv1",
                    "type": "bssv1"
                }
            ],
            "domain": {
                "id": "d78cbac186b744899480f25bd022f...",
                "name": "IAMDomain"
            },
            "expires_at": "2020-01-04T09:08:49.965000Z",
            "issued_at": "2020-01-03T09:08:49.965000Z",
            "methods": [
                "password"
            ],
            "roles": [
                {
                    "id": "0",
                    "name": "te_admin"
                },
                {
                    "id": "0",
                    "name": "secu_admin"
                },
                {
                    "id": "0",
                    "name": "te_agency"
                }
            ],
            "user": {
                "domain": {
                    "id": "d78cbac186b744899480f25bd022f...",
                    "name": "IAMDomain"
                },
                "id": "7116d09f88fa41908676fdd4b039e...",
                "name": "IAMUser",
                "password_expires_at": ""
            }
        }
    }

状态码为 400 时:

参数无效。请排查body体是否符合json语法。

{
    "error": {
        "code": 400,
        "message": "The request body is invalid",
        "title": "Bad Request"
    }
}

状态码为 401 时:

认证失败。

  • 如果您是第三方系统用户,直接使用联邦认证的用户名和密码 获取Token ,系统会提示密码错误。请在华为云的登录页面,通过“忘记密码”功能,设置华为云账号密码,并在password中输入新设置的密码。
  • 如果您的华为云账号已升级为华为账号,直接使用华为账号名和密码获取Token,系统会提示密码错误。建议您为自己创建一个IAM用户,授予该用户必要的权限,获取IAM用户Token。
{
    "error": {
        "code": 401,
        "message": "The username or password is wrong.",
        "title": "Unauthorized"
    }
}
support.huaweicloud.com/api-iam/iam_30_0001.html