创建 identityProvider
命名空间:microsoft.graph
创建一个标识提供程序资源,该资源的类型为请求正文中指定的类型。
在从 identityProviderBase 派生的提供程序类型中,当前可以在 Azure AD 创建socialIdentityProvider资源。 在 Azure AD B2C 中,此操作当前可以创建socialIdentityProvider或appleManagedIdentityProvider资源。
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 提供socialIdentityProvider或appleManagedIdentityProvider对象的 JSON 表示形式。
socialIdentityProvider 对象
| 属性 |
类型 |
说明 |
| clientId |
字符串 |
向标识提供程序注册应用程序时,获取应用程序的客户端标识符。 |
| clientSecret |
字符串 |
向标识提供程序注册时获取的应用程序的客户端密码。 这是只读的。 读取操作返回 ****。 |
| displayName |
字符串 |
标识提供程序的显示名称。 |
| identityProviderType |
String |
对于 B2B 方案,可能的值为: Google、 Facebook。 对于 B2C 方案,可能的值: Microsoft、 Google、 Amazon、 LinkedIn、 Facebook、 GitHub、 Twitter、 Weibo、 QQ、 WeChat。 |
| 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 socialIdentityProvider或appleManagedIdentityProvider对象的 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"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var identityProviderBase = new SocialIdentityProvider
{
DisplayName = "Login with Amazon",
IdentityProviderType = "Amazon",
ClientId = "56433757-cadd-4135-8431-2c9e3fd68ae8",
ClientSecret = "000000000000"
};
await graphClient.Identity.IdentityProviders
.Request()
.AddAsync(identityProviderBase);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const identityProviderBase = {
'@odata.type': 'microsoft.graph.socialIdentityProvider',
displayName: 'Login with Amazon',
identityProviderType: 'Amazon',
clientId: '56433757-cadd-4135-8431-2c9e3fd68ae8',
clientSecret: '000000000000'
};
await client.api('/identity/identityProviders')
.post(identityProviderBase);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/identity/identityProviders"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphIdentityProviderBase *identityProviderBase = [[MSGraphIdentityProviderBase alloc] init];
[identityProviderBase setDisplayName:@"Login with Amazon"];
[identityProviderBase setIdentityProviderType:@"Amazon"];
[identityProviderBase setClientId:@"56433757-cadd-4135-8431-2c9e3fd68ae8"];
[identityProviderBase setClientSecret:@"000000000000"];
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];
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
SocialIdentityProvider identityProviderBase = new SocialIdentityProvider();
identityProviderBase.displayName = "Login with Amazon";
identityProviderBase.identityProviderType = "Amazon";
identityProviderBase.clientId = "56433757-cadd-4135-8431-2c9e3fd68ae8";
identityProviderBase.clientSecret = "000000000000";
graphClient.identity().identityProviders()
.buildRequest()
.post(identityProviderBase);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewIdentityProviderBase()
displayName := "Login with Amazon"
requestBody.SetDisplayName(&displayName)
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.socialIdentityProvider",
"identityProviderType": "Amazon",
"clientId": "56433757-cadd-4135-8431-2c9e3fd68ae8",
"clientSecret": "000000000000",
}
result, err := graphClient.Identity().IdentityProviders().Post(requestBody)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
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": "******"
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var identityProviderBase = new AppleManagedIdentityProvider
{
DisplayName = "Sign in with Apple",
DeveloperId = "UBF8T346G9",
ServiceId = "com.microsoft.rts.b2c.test.client",
KeyId = "99P6D879C4",
CertificateData = "******"
};
await graphClient.Identity.IdentityProviders
.Request()
.AddAsync(identityProviderBase);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
const options = {
authProvider,
};
const client = Client.init(options);
const identityProviderBase = {
'@odata.type': 'microsoft.graph.appleManagedIdentityProvider',
displayName: 'Sign in with Apple',
developerId: 'UBF8T346G9',
serviceId: 'com.microsoft.rts.b2c.test.client',
keyId: '99P6D879C4',
certificateData: '******'
};
await client.api('/identity/identityProviders')
.post(identityProviderBase);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
MSHTTPClient *httpClient = [MSClientFactory createHTTPClientWithAuthenticationProvider:authenticationProvider];
NSString *MSGraphBaseURL = @"https://graph.microsoft.com/v1.0/";
NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:[MSGraphBaseURL stringByAppendingString:@"/identity/identityProviders"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphIdentityProviderBase *identityProviderBase = [[MSGraphIdentityProviderBase alloc] init];
[identityProviderBase setDisplayName:@"Sign in with Apple"];
[identityProviderBase setDeveloperId:@"UBF8T346G9"];
[identityProviderBase setServiceId:@"com.microsoft.rts.b2c.test.client"];
[identityProviderBase setKeyId:@"99P6D879C4"];
[identityProviderBase setCertificateData:@"******"];
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];
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
GraphServiceClient graphClient = GraphServiceClient.builder().authenticationProvider( authProvider ).buildClient();
AppleManagedIdentityProvider identityProviderBase = new AppleManagedIdentityProvider();
identityProviderBase.displayName = "Sign in with Apple";
identityProviderBase.developerId = "UBF8T346G9";
identityProviderBase.serviceId = "com.microsoft.rts.b2c.test.client";
identityProviderBase.keyId = "99P6D879C4";
identityProviderBase.certificateData = "******";
graphClient.identity().identityProviders()
.buildRequest()
.post(identityProviderBase);
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewIdentityProviderBase()
displayName := "Sign in with Apple"
requestBody.SetDisplayName(&displayName)
requestBody.SetAdditionalData(map[string]interface{}{
"@odata.type": "microsoft.graph.appleManagedIdentityProvider",
"developerId": "UBF8T346G9",
"serviceId": "com.microsoft.rts.b2c.test.client",
"keyId": "99P6D879C4",
"certificateData": "******",
}
result, err := graphClient.Identity().IdentityProviders().Post(requestBody)
有关如何将 SDK 添加 到项目并 创建 authProvider 实例的 详细信息,请参阅 SDK 文档。
响应
下面展示了示例响应。
注意: 为了提高可读性,可能缩短了此处显示的响应对象。
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": "******"
}