更新 identityProvider
本文内容
命名空间:microsoft.graph
重要
Microsoft Graph版本下的 /beta API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
更新在租户中配置的指定标识提供程序的属性。
在从 identityProviderBase 派生的提供程序类型中,当前可以在 Azure AD 中更新socialIdentityProvider 资源。 在 Azure AD B2C 中,此操作当前可以更新 socialIdentityProvider、openIdConnectIdentityProvider 或appleManagedIdentityProvider 资源。
权限
要调用此 API,需要以下权限之一。要了解详细信息,包括如何选择权限的信息,请参阅权限 。
权限类型
权限(从最低特权到最高特权)
委派(工作或学校帐户)
IdentityProvider.ReadWrite.All
委派(Microsoft 个人帐户)
不支持。
应用程序
IdentityProvider.ReadWrite.All
工作或学校帐户需要属于以下角色之一:
HTTP 请求
PATCH /identity/identityProviders/{id}
名称
说明
Authorization
Bearer {token}。必需。
Content-Type
application/json. Required.
请求正文
在请求正文中,为 JSON 对象提供一个或多个属性,这些属性需要在租户中为socialIdentityProvider Azure AD更新。
在 Azure AD B2C 中,为 JSON 对象提供一个或多个属性,这些属性需要针对 socialIdentityProvider、openIdConnectIdentityProvider 或appleManagedIdentityProvider 对象进行更新。
socialIdentityProvider 对象
属性
类型
说明
clientId
字符串
向标识提供程序注册应用程序时,获取应用程序的客户端标识符。
clientSecret
字符串
向标识提供程序注册时获取的应用程序的客户端密码。 这是只读的。 读取操作返回 ****。
displayName
字符串
标识提供程序的显示名称。
openIdConnectIdentityProvider 对象
属性
类型
说明
clientId
字符串
向标识提供程序注册应用程序时,获取应用程序的客户端标识符。
clientSecret
字符串
使用身份提供程序注册应用时获取的应用客户端密码。 clientSecret 依赖于 responseType 。 当 responseType code 为 时,身份验证代码交换需要密码。 当 responseType id_token 为密码时不是必需的,因为没有代码交换。 授权id_token返回授权。
displayName
字符串
标识提供程序的显示名称。
domainHint
String
域提示可用于直接跳到指定标识提供程序的登录页面,而不是让用户在可用标识提供程序列表中进行选择。
claimsMapping
claimsMapping
在 OIDC 提供程序将 ID 令牌发送回 Azure AD 后,Azure AD 需要能够将收到的令牌中的声明映射到 Azure AD 识别并使用声明。 此复杂类型捕获该映射。
metadataUrl
String
OpenID 元数据文档的 URL 连接提供程序。 每个 OpenID 连接标识提供程序都描述一个元数据文档,其中包含执行登录所需的大部分信息。 这包括要使用的 URL 以及服务的公共签名密钥的位置等信息。 OpenID 连接元数据文档始终位于 以 结尾的终结点 .well-known/openid-configuration 。 提供您添加的 OpenID 连接标识提供程序的元数据 URL。
responseMode
String
响应模式定义用于将数据从自定义标识提供程序发送回 B2C Azure AD的方法。 可能的值 form_post query :、。
responseType
String
响应类型描述在初始调用中发送回自定义标识提供程序authorization_endpoint类型。 可能的值 code id_token token :、、。
scope
String
范围定义要从自定义标识提供程序收集的信息和权限。
appleManagedIdentityProvider 对象
属性
类型
说明
displayName
字符串
标识提供程序的显示名称。
developerId
String
Apple 开发人员标识符。
服务 Id
String
Apple 服务标识符。
keyId
String
Apple 密钥标识符。
certificateData
String
证书中长文本字符串的证书数据可能是 null。
响应
如果成功,此方法返回 204 No Content 响应代码。 如果失败,将返回 4xx 错误并显示具体详细信息。
示例
示例 1:更新特定 社会标识提供程序 (Azure AD 或Azure AD B2C)
请求
下面展示了示例请求。
PATCH https://graph.microsoft.com/beta/identity/identityProviders/Amazon-OAUTH
Content-type: application/json
{
"@odata.type": "#microsoft.graph.socialIdentityProvider",
"clientSecret": "1111111111111"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var identityProviderBase = new SocialIdentityProvider
{
ClientSecret = "1111111111111"
};
await graphClient.Identity.IdentityProviders["{identityProviderBase-id}"]
.Request()
.UpdateAsync(identityProviderBase);
const options = {
authProvider,
};
const client = Client.init(options);
const identityProviderBase = {
'@odata.type': '#microsoft.graph.socialIdentityProvider',
clientSecret: '1111111111111'
};
await client.api('/identity/identityProviders/Amazon-OAUTH')
.version('beta')
.update(identityProviderBase);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/identity/identityProviders/Amazon-OAUTH"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphIdentityProviderBase *identityProviderBase = [[MSGraphIdentityProviderBase alloc] init];
[identityProviderBase setClientSecret:@"1111111111111"];
NSError *error;
NSData *identityProviderBaseData = [identityProviderBase getSerializedDataWithError:&error];
[urlRequest setHTTPBody:identityProviderBaseData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
SocialIdentityProvider identityProviderBase = new SocialIdentityProvider();
identityProviderBase.clientSecret = "1111111111111";
graphClient.identity().identityProviders("Amazon-OAUTH")
.buildRequest()
.patch(identityProviderBase);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewIdentityProviderBase()
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.socialIdentityProvider",
"clientSecret": "1111111111111",
}
identityProviderBaseId := "identityProviderBase-id"
graphClient.Identity().IdentityProvidersById(&identityProviderBaseId).Patch(requestBody)
响应
下面展示了示例响应。
HTTP/1.1 204 No Content
示例 2:仅针对 连接 B2C (更新Azure AD OpenID )
请求
下面展示了示例请求。
PATCH https://graph.microsoft.com/beta/identity/identityProviders/OIDC-V1-Nam_AD_Test-3e393390-ed2d-4794-97f6-5c999ccc61f7
Content-type: application/json
{
"@odata.type": "#microsoft.graph.socialIdentityProvider",
"responseType": "id_token"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var identityProviderBase = new SocialIdentityProvider
{
ResponseType = OpenIdConnectResponseTypes.Id_token
};
await graphClient.Identity.IdentityProviders["{identityProviderBase-id}"]
.Request()
.UpdateAsync(identityProviderBase);
const options = {
authProvider,
};
const client = Client.init(options);
const identityProviderBase = {
'@odata.type': '#microsoft.graph.socialIdentityProvider',
responseType: 'id_token'
};
await client.api('/identity/identityProviders/OIDC-V1-Nam_AD_Test-3e393390-ed2d-4794-97f6-5c999ccc61f7')
.version('beta')
.update(identityProviderBase);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/identityProviders/OIDC-V1-MyTest-085a8a0c-58cb-4b6d-8e07-1328ea404e1a"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphIdentityProvider *identityProvider = [[MSGraphIdentityProvider alloc] init];
[identityProvider setResponseType: [MSGraphOpenIdConnectResponseTypes id_token]];
NSError *error;
NSData *identityProviderData = [identityProvider getSerializedDataWithError:&error];
[urlRequest setHTTPBody:identityProviderData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
SocialIdentityProvider identityProviderBase = new SocialIdentityProvider();
identityProviderBase.responseType = EnumSet.of(OpenIdConnectResponseTypes.ID_TOKEN);
graphClient.identity().identityProviders("OIDC-V1-Nam_AD_Test-3e393390-ed2d-4794-97f6-5c999ccc61f7")
.buildRequest()
.patch(identityProviderBase);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewIdentityProvider()
requestBody.SetAdditionalData(map[string]interface{}{
"responseType": "id_token",
}
identityProviderId := "identityProvider-id"
graphClient.IdentityProvidersById(&identityProviderId).Patch(requestBody)
Import-Module Microsoft.Graph.Identity.SignIns
$params = @{
ResponseType = "id_token"
}
Update-MgIdentityProvider -IdentityProviderId $identityProviderId -BodyParameter $params
响应
下面展示了示例响应。
HTTP/1.1 204 No Content
示例 3:仅为B2C (更新Azure AD Apple 标识)
请求
下面展示了示例请求。
PATCH https://graph.microsoft.com/beta/identity/identityProviders/Apple-Managed-OIDC
Content-type: application/json
{
"@odata.type": "#microsoft.graph.socialIdentityProvider",
"displayName": "Apple"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var identityProviderBase = new SocialIdentityProvider
{
DisplayName = "Apple"
};
await graphClient.Identity.IdentityProviders["{identityProviderBase-id}"]
.Request()
.UpdateAsync(identityProviderBase);
const options = {
authProvider,
};
const client = Client.init(options);
const identityProviderBase = {
'@odata.type': '#microsoft.graph.socialIdentityProvider',
displayName: 'Apple'
};
await client.api('/identity/identityProviders/Apple-Managed-OIDC')
.version('beta')
.update(identityProviderBase);
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/beta/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/identity/identityProviders/Apple-Managed-OIDC"]]];
[urlRequest setHTTPMethod:@"PATCH"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphIdentityProviderBase *identityProviderBase = [[MSGraphIdentityProviderBase alloc] init];
[identityProviderBase setDisplayName:@"Apple"];
NSError *error;
NSData *identityProviderBaseData = [identityProviderBase getSerializedDataWithError:&error];
[urlRequest setHTTPBody:identityProviderBaseData];
MSURLSessionDataTask *meDataTask = [httpClient dataTaskWithRequest:urlRequest
completionHandler: ^(NSData *data, NSURLResponse *response, NSError *nserror) {
//Request Completed
}];
[meDataTask execute];
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
SocialIdentityProvider identityProviderBase = new SocialIdentityProvider();
identityProviderBase.displayName = "Apple";
graphClient.identity().identityProviders("Apple-Managed-OIDC")
.buildRequest()
.patch(identityProviderBase);
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewIdentityProviderBase()
displayName := "Apple"
requestBody.SetDisplayName(&displayName)
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.socialIdentityProvider",
}
identityProviderBaseId := "identityProviderBase-id"
graphClient.Identity().IdentityProvidersById(&identityProviderBaseId).Patch(requestBody)
响应
下面展示了示例响应。
HTTP/1.1 204 No Content