创建 identityProvider

命名空间:microsoft.graph

创建一个标识提供程序资源,该资源的类型为请求正文中指定的类型。

在从 identityProviderBase 派生的提供程序类型中,当前可以在 Azure AD 创建socialIdentityProvider资源。 在 Azure AD B2C 中,此操作当前可以创建socialIdentityProviderappleManagedIdentityProvider资源。

Permissions

要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限

权限类型 权限(从最低特权到最高特权)
委派(工作或学校帐户) IdentityProvider.ReadWrite.All
委派(Microsoft 个人帐户) 不支持。
应用程序 IdentityProvider.ReadWrite.All

工作或学校帐户需要属于以下角色之一:

  • 全局管理员
  • 外部标识提供程序管理员

HTTP 请求

POST /identity/identityProviders

请求标头

名称 说明
Authorization Bearer {token}。必需。
Content-Type application/json. Required.

请求正文

在请求正文中,在请求正文中提供socialIdentityProvider对象的 JSON Azure AD。

在Azure AD B2C 提供socialIdentityProviderappleManagedIdentityProvider对象的 JSON 表示形式。

socialIdentityProvider 对象

属性 类型 说明
clientId 字符串 向标识提供程序注册应用程序时,获取应用程序的客户端标识符。
clientSecret 字符串 向标识提供程序注册时获取的应用程序的客户端密码。 这是只读的。 读取操作返回 ****
displayName 字符串 标识提供程序的显示名称。
identityProviderType String 对于 B2B 方案,可能的值为: GoogleFacebook。 对于 B2C 方案,可能的值: MicrosoftGoogleAmazonLinkedInFacebookGitHubTwitterWeiboQQWeChat
scope String 范围定义要从自定义标识提供程序收集的信息和权限。

appleIdentityProvider 对象

属性 类型 说明
displayName 字符串 标识提供程序的显示名称。
developerId String Apple 开发人员标识符。
服务 Id String Apple 服务标识符。
keyId String Apple 密钥标识符。
certificateData String 证书中长文本字符串的证书数据可能是 null。

响应

如果成功,此方法在 Azure AD 租户的响应正文中返回 201 Created socialIdentityProvider对象的响应代码和 JSON 表示形式。

对于 Azure AD B2C 租户,此方法在响应正文中返回 响应代码和 201 Created socialIdentityProviderappleManagedIdentityProvider对象的 JSON 表示形式。

如果失败,将返回 4xx 错误并显示具体详细信息。

示例

示例 1:创建特定的社会标识提供程序 (Azure AD Azure AD B2C)

请求

下面展示了示例请求。

POST https://graph.microsoft.com/v1.0/identity/identityProviders
Content-type: application/json

{
  "@odata.type": "microsoft.graph.socialIdentityProvider",
  "displayName": "Login with Amazon",
  "identityProviderType": "Amazon",
  "clientId": "56433757-cadd-4135-8431-2c9e3fd68ae8",
  "clientSecret": "000000000000"
}

响应

下面展示了示例响应。

注意: 为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
    "@odata.type": "microsoft.graph.socialIdentityProvider",
    "id": "Amazon-OAUTH",
    "displayName": "Login with Amazon",
    "identityProviderType": "Amazon",
    "clientId": "56433757-cadd-4135-8431-2c9e3fd68ae8",
    "clientSecret": "000000000000"
}

示例 2:仅为 (B2C Azure AD检索 Apple 标识)

请求

下面展示了示例请求。

POST https://graph.microsoft.com/v1.0/identity/identityProviders
Content-type: application/json

{
  "@odata.type": "microsoft.graph.appleManagedIdentityProvider",
  "displayName": "Sign in with Apple",
  "developerId": "UBF8T346G9",
  "serviceId": "com.microsoft.rts.b2c.test.client",
  "keyId": "99P6D879C4",
  "certificateData": "******"
}

响应

下面展示了示例响应。

注意: 为了提高可读性,可能缩短了此处显示的响应对象。

HTTP/1.1 201 Created
Content-type: application/json

{
  "@odata.type": "microsoft.graph.appleManagedIdentityProvider",
  "id": "Apple-Managed-OIDC",
  "displayName": "Sign in with Apple",
  "developerId": "UBF8T346G9",
  "serviceId": "com.microsoft.rts.b2c.test.client",
  "keyId": "99P6D879C4",
  "certificateData": "******"
}