
# 创建外部身份提供商配置 - CreateExternalIdPConfigurationForDirectory
#### 功能介绍
创建外部身份提供商配置。此操作只能由组织的管理账号或作为服务委托管理员的成员账号调用。
#### 授权信息
账号根用户具备所有API的调用权限，如果使用账号下的IAM用户调用当前API，该IAM用户需具备如下身份策略权限，更多的权限说明请参见[权限和授权项](https://support.huaweicloud.com/api-identitycenter/iic_04_0028.html)。
| 授权项                               | 访问级别  | 资源类型（\*为必须） | 条件键 | 别名 | 依赖的授权项                                     |
|:---|:---|:---|:---|:---|:---|
| IdentityCenter:externalIdp:create | Write | -           | -   | -  | organizations:delegatedAdministrators:list |
   
#### 调试
您可以在[API Explorer](https://console.huaweicloud.com/apiexplorer/#/openapi/IdentityCenter/doc?api=CreateExternalIdPConfigurationForDirectory)中调试该接口，支持自动认证鉴权。API Explorer可以自动生成SDK代码示例，并提供SDK代码示例调试功能。
#### URI
POST /v1/identity-stores/{identity_store_id}/external-idp
表1路径参数 
| 参数                | 是否必选 | 参数类型   | 描述              |
|:---|:---|:---|:---|
| identity_store_id | 是    | String | 身份源的全局唯一标识符（ID） |
   
#### 请求参数
表2请求Header参数 
| 参数               | 是否必选 | 参数类型   | 描述                                              |
|:---|:---|:---|:---|
| X-Security-Token | 否    | String | 如果正在使用临时安全凭据，则此header是必需的，该值是临时安全凭据的安全令牌（会话令牌）。 |
   
表3请求Body参数 
| 参数                | 是否必选 | 参数类型                                                                                           | 描述                             |
|:---|:---|:---|:---|
| idp_saml_metadata | 否    | String                                                                                         | 身份提供商SAML元数据，与身份提供商SAML配置二选一   |
| idp_certificate   | 否    | String                                                                                         | 身份提供商证书，与身份提供商SAML配置联合使用       |
| idp_saml_config   | 否    | [idp_saml_config] object | 身份提供商SAML配置信息，与身份提供商SAML元数据二选一 |
   
 表4idp_saml_config 
| 参数        | 是否必选 | 参数类型   | 描述         |
|:---|:---|:---|:---|
| entity_id | 否    | String | 身份提供商发布者标识 |
| login_url | 否    | String | 身份提供商登录链接  |
   
#### 响应参数
**状态码：201**
表5响应Body参数 
| 参数                  | 参数类型                                                                                      | 描述                  |
|:---|:---|:---|
| hws_sp_saml_config  | [SPSAMLConfig] object | 服务提供商配置信息           |
| idp_certificate_id  | String                                                                                    | 身份提供商证书全局唯一标识符（ID)  |
| idp_certificate_ids | Array of strings                                                                          | 身份提供商证书全局唯一标识符列表    |
| idp_id              | String                                                                                    | 外部身份提供商的全局唯一标识符（ID） |
   
 表6SPSAMLConfig 
| 参数       | 参数类型   | 描述          |
|:---|:---|:---|
| acs_url  | String | 服务提供商断言响应地址 |
| issuer   | String | 服务提供商签发者    |
| metadata | String | 服务提供商元数据    |
   
**状态码：400**
表7响应Body参数 
| 参数         | 参数类型   | 描述     |
|:---|:---|:---|
| error_code | String | 错误码    |
| error_msg  | String | 错误信息   |
| request_id | String | 请求唯一标识 |
   
**状态码：403**
表8响应Body参数 
| 参数                            | 参数类型   | 描述      |
|:---|:---|:---|
| error_code                    | String | 错误码     |
| error_msg                     | String | 错误信息    |
| request_id                    | String | 请求唯一标识  |
| encoded_authorization_message | String | 加密的错误信息 |
   
#### 请求示例
创建外部身份提供商配置
```
POST https://{hostname}/v1/identity-stores/{identity_store_id}/external-idp
{
  "idp_saml_metadata" : "<?xml version=\"1.0\" encoding=\"utf-8\"?><EntityDescriptor ID=\"_678cd4a8-4915-4e2d-a4ce-6*************cd/saml2\" /></IDPSSODescriptor></EntityDescriptor>"
}
```
#### 响应示例
**状态码：201**
Successful
```
{
  "hws_sp_saml_config" : {
    "acs_url" : "https://cn-north-4-signin.huaweicloud.com/v1/platform/saml/acs/xxxxxxx",
    "issuer" : "https://cn-north-4.signin.huaweicloud.com/platform/saml/xxxxxx",
    "metadata" : "<?xml version=\"1.0\" encoding=\"UTF-8\"?>xxxxxxx</md:EntityDescriptor>"
  },
  "idp_certificate_id" : "553523a6-ebde-4570-xxxxxxx",
  "idp_certificate_ids" : [ "553523a6-ebde-4570-xxxxxxx" ],
  "idp_id" : "a48e3f1b-59f8-4b8f-xxxxxxx"
}
```
#### 状态码
| 状态码 | 描述          |
|:---|:---|
| 201 | Successful  |
| 400 | Bad request |
| 403 | Forbidden   |
   
#### 错误码
请参见[错误码](https://support.huaweicloud.com/api-identitycenter/ErrorCode.html)。
