命名空间:microsoft.graph
重要
Microsoft Graph /beta
版本下的 API 可能会发生更改。 不支持在生产应用程序中使用这些 API。 若要确定 API 是否在 v1.0 中可用,请使用 版本 选择器。
创建新的 customAuthenticationExtension 对象。 当前支持以下派生类型。
此 API 可用于以下国家级云部署。
全局服务 |
美国政府 L4 |
美国政府 L5 (DOD) |
由世纪互联运营的中国 |
✅ |
✅ |
✅ |
✅ |
权限
为此 API 选择标记为最低特权的权限。
只有在应用需要它时,才使用更高的特权权限。 有关委派权限和应用程序权限的详细信息,请参阅权限类型。 要了解有关这些权限的详细信息,请参阅 权限参考。
权限类型 |
最低特权权限 |
更高特权权限 |
委派(工作或学校帐户) |
CustomAuthenticationExtension.ReadWrite.All |
不可用。 |
委派(个人 Microsoft 帐户) |
不支持。 |
不支持。 |
应用程序 |
CustomAuthenticationExtension.ReadWrite.All |
不可用。 |
HTTP 请求
POST /identity/customAuthenticationExtensions
名称 |
说明 |
Authorization |
持有者 {token}。 必填。 详细了解 身份验证和授权。 |
Content-Type |
application/json. 必需。 |
请求正文
在请求正文中,提供 customAuthenticationExtension 对象的 JSON 表示形式。
在创建自定义 AuthenticationExtension 时,可以指定以下属性。 必须使用要创建的 customAuthenticationExtension 对象类型的值指定 @odata.type 属性。 例如,若要创建 onTokenIssuanceStartCustomExtension 对象,请将 @odata.type 设置为 #microsoft.graph.onTokenIssuanceStartCustomExtension
。
响应
如果成功,此方法在响应正文中返回响应 201 Created
代码和 customAuthenticationExtension 对象。
示例
示例 1:创建 onTokenIssuanceStartCustomExtension 对象
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/beta/identity/customAuthenticationExtensions
Content-Type: application/json
Content-length: 468
{
"@odata.type": "#microsoft.graph.onTokenIssuanceStartCustomExtension",
"displayName": "onTokenIssuanceStartCustomExtension",
"description": "Fetch additional claims from custom user store",
"endpointConfiguration": {
"@odata.type": "#microsoft.graph.httpRequestEndpoint",
"targetUrl": "https://authenticationeventsAPI.contoso.com"
},
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",
"resourceId": "api://authenticationeventsAPI.contoso.com/a13d0fc1-04ab-4ede-b215-63de0174cbb4"
},
"clientConfiguration": {
"timeoutInMilliseconds": 2000,
"maximumRetries": 1
},
"claimsForTokenConfiguration": [
{
"claimIdInApiResponse": "DateOfBirth"
},
{
"claimIdInApiResponse": "CustomRoles"
}
]
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new OnTokenIssuanceStartCustomExtension
{
OdataType = "#microsoft.graph.onTokenIssuanceStartCustomExtension",
DisplayName = "onTokenIssuanceStartCustomExtension",
Description = "Fetch additional claims from custom user store",
EndpointConfiguration = new HttpRequestEndpoint
{
OdataType = "#microsoft.graph.httpRequestEndpoint",
TargetUrl = "https://authenticationeventsAPI.contoso.com",
},
AuthenticationConfiguration = new AzureAdTokenAuthentication
{
OdataType = "#microsoft.graph.azureAdTokenAuthentication",
ResourceId = "api://authenticationeventsAPI.contoso.com/a13d0fc1-04ab-4ede-b215-63de0174cbb4",
},
ClientConfiguration = new CustomExtensionClientConfiguration
{
TimeoutInMilliseconds = 2000,
MaximumRetries = 1,
},
ClaimsForTokenConfiguration = new List<OnTokenIssuanceStartReturnClaim>
{
new OnTokenIssuanceStartReturnClaim
{
ClaimIdInApiResponse = "DateOfBirth",
},
new OnTokenIssuanceStartReturnClaim
{
ClaimIdInApiResponse = "CustomRoles",
},
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Identity.CustomAuthenticationExtensions.PostAsync(requestBody);
mgc-beta identity custom-authentication-extensions create --body '{\
"@odata.type": "#microsoft.graph.onTokenIssuanceStartCustomExtension",\
"displayName": "onTokenIssuanceStartCustomExtension",\
"description": "Fetch additional claims from custom user store",\
"endpointConfiguration": {\
"@odata.type": "#microsoft.graph.httpRequestEndpoint",\
"targetUrl": "https://authenticationeventsAPI.contoso.com"\
},\
"authenticationConfiguration": {\
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",\
"resourceId": "api://authenticationeventsAPI.contoso.com/a13d0fc1-04ab-4ede-b215-63de0174cbb4"\
},\
"clientConfiguration": {\
"timeoutInMilliseconds": 2000,\
"maximumRetries": 1\
},\
"claimsForTokenConfiguration": [\
{\
"claimIdInApiResponse": "DateOfBirth"\
},\
{\
"claimIdInApiResponse": "CustomRoles"\
}\
]\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewCustomAuthenticationExtension()
displayName := "onTokenIssuanceStartCustomExtension"
requestBody.SetDisplayName(&displayName)
description := "Fetch additional claims from custom user store"
requestBody.SetDescription(&description)
endpointConfiguration := graphmodels.NewHttpRequestEndpoint()
targetUrl := "https://authenticationeventsAPI.contoso.com"
endpointConfiguration.SetTargetUrl(&targetUrl)
requestBody.SetEndpointConfiguration(endpointConfiguration)
authenticationConfiguration := graphmodels.NewAzureAdTokenAuthentication()
resourceId := "api://authenticationeventsAPI.contoso.com/a13d0fc1-04ab-4ede-b215-63de0174cbb4"
authenticationConfiguration.SetResourceId(&resourceId)
requestBody.SetAuthenticationConfiguration(authenticationConfiguration)
clientConfiguration := graphmodels.NewCustomExtensionClientConfiguration()
timeoutInMilliseconds := int32(2000)
clientConfiguration.SetTimeoutInMilliseconds(&timeoutInMilliseconds)
maximumRetries := int32(1)
clientConfiguration.SetMaximumRetries(&maximumRetries)
requestBody.SetClientConfiguration(clientConfiguration)
onTokenIssuanceStartReturnClaim := graphmodels.NewOnTokenIssuanceStartReturnClaim()
claimIdInApiResponse := "DateOfBirth"
onTokenIssuanceStartReturnClaim.SetClaimIdInApiResponse(&claimIdInApiResponse)
onTokenIssuanceStartReturnClaim1 := graphmodels.NewOnTokenIssuanceStartReturnClaim()
claimIdInApiResponse := "CustomRoles"
onTokenIssuanceStartReturnClaim1.SetClaimIdInApiResponse(&claimIdInApiResponse)
claimsForTokenConfiguration := []graphmodels.OnTokenIssuanceStartReturnClaimable {
onTokenIssuanceStartReturnClaim,
onTokenIssuanceStartReturnClaim1,
}
requestBody.SetClaimsForTokenConfiguration(claimsForTokenConfiguration)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
customAuthenticationExtensions, err := graphClient.Identity().CustomAuthenticationExtensions().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
OnTokenIssuanceStartCustomExtension customAuthenticationExtension = new OnTokenIssuanceStartCustomExtension();
customAuthenticationExtension.setOdataType("#microsoft.graph.onTokenIssuanceStartCustomExtension");
customAuthenticationExtension.setDisplayName("onTokenIssuanceStartCustomExtension");
customAuthenticationExtension.setDescription("Fetch additional claims from custom user store");
HttpRequestEndpoint endpointConfiguration = new HttpRequestEndpoint();
endpointConfiguration.setOdataType("#microsoft.graph.httpRequestEndpoint");
endpointConfiguration.setTargetUrl("https://authenticationeventsAPI.contoso.com");
customAuthenticationExtension.setEndpointConfiguration(endpointConfiguration);
AzureAdTokenAuthentication authenticationConfiguration = new AzureAdTokenAuthentication();
authenticationConfiguration.setOdataType("#microsoft.graph.azureAdTokenAuthentication");
authenticationConfiguration.setResourceId("api://authenticationeventsAPI.contoso.com/a13d0fc1-04ab-4ede-b215-63de0174cbb4");
customAuthenticationExtension.setAuthenticationConfiguration(authenticationConfiguration);
CustomExtensionClientConfiguration clientConfiguration = new CustomExtensionClientConfiguration();
clientConfiguration.setTimeoutInMilliseconds(2000);
clientConfiguration.setMaximumRetries(1);
customAuthenticationExtension.setClientConfiguration(clientConfiguration);
LinkedList<OnTokenIssuanceStartReturnClaim> claimsForTokenConfiguration = new LinkedList<OnTokenIssuanceStartReturnClaim>();
OnTokenIssuanceStartReturnClaim onTokenIssuanceStartReturnClaim = new OnTokenIssuanceStartReturnClaim();
onTokenIssuanceStartReturnClaim.setClaimIdInApiResponse("DateOfBirth");
claimsForTokenConfiguration.add(onTokenIssuanceStartReturnClaim);
OnTokenIssuanceStartReturnClaim onTokenIssuanceStartReturnClaim1 = new OnTokenIssuanceStartReturnClaim();
onTokenIssuanceStartReturnClaim1.setClaimIdInApiResponse("CustomRoles");
claimsForTokenConfiguration.add(onTokenIssuanceStartReturnClaim1);
customAuthenticationExtension.setClaimsForTokenConfiguration(claimsForTokenConfiguration);
CustomAuthenticationExtension result = graphClient.identity().customAuthenticationExtensions().post(customAuthenticationExtension);
const options = {
authProvider,
};
const client = Client.init(options);
const customAuthenticationExtension = {
'@odata.type': '#microsoft.graph.onTokenIssuanceStartCustomExtension',
displayName: 'onTokenIssuanceStartCustomExtension',
description: 'Fetch additional claims from custom user store',
endpointConfiguration: {
'@odata.type': '#microsoft.graph.httpRequestEndpoint',
targetUrl: 'https://authenticationeventsAPI.contoso.com'
},
authenticationConfiguration: {
'@odata.type': '#microsoft.graph.azureAdTokenAuthentication',
resourceId: 'api://authenticationeventsAPI.contoso.com/a13d0fc1-04ab-4ede-b215-63de0174cbb4'
},
clientConfiguration: {
timeoutInMilliseconds: 2000,
maximumRetries: 1
},
claimsForTokenConfiguration: [
{
claimIdInApiResponse: 'DateOfBirth'
},
{
claimIdInApiResponse: 'CustomRoles'
}
]
};
await client.api('/identity/customAuthenticationExtensions')
.version('beta')
.post(customAuthenticationExtension);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\OnTokenIssuanceStartCustomExtension;
use Microsoft\Graph\Beta\Generated\Models\HttpRequestEndpoint;
use Microsoft\Graph\Beta\Generated\Models\AzureAdTokenAuthentication;
use Microsoft\Graph\Beta\Generated\Models\CustomExtensionClientConfiguration;
use Microsoft\Graph\Beta\Generated\Models\OnTokenIssuanceStartReturnClaim;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new OnTokenIssuanceStartCustomExtension();
$requestBody->setOdataType('#microsoft.graph.onTokenIssuanceStartCustomExtension');
$requestBody->setDisplayName('onTokenIssuanceStartCustomExtension');
$requestBody->setDescription('Fetch additional claims from custom user store');
$endpointConfiguration = new HttpRequestEndpoint();
$endpointConfiguration->setOdataType('#microsoft.graph.httpRequestEndpoint');
$endpointConfiguration->setTargetUrl('https://authenticationeventsAPI.contoso.com');
$requestBody->setEndpointConfiguration($endpointConfiguration);
$authenticationConfiguration = new AzureAdTokenAuthentication();
$authenticationConfiguration->setOdataType('#microsoft.graph.azureAdTokenAuthentication');
$authenticationConfiguration->setResourceId('api://authenticationeventsAPI.contoso.com/a13d0fc1-04ab-4ede-b215-63de0174cbb4');
$requestBody->setAuthenticationConfiguration($authenticationConfiguration);
$clientConfiguration = new CustomExtensionClientConfiguration();
$clientConfiguration->setTimeoutInMilliseconds(2000);
$clientConfiguration->setMaximumRetries(1);
$requestBody->setClientConfiguration($clientConfiguration);
$claimsForTokenConfigurationOnTokenIssuanceStartReturnClaim1 = new OnTokenIssuanceStartReturnClaim();
$claimsForTokenConfigurationOnTokenIssuanceStartReturnClaim1->setClaimIdInApiResponse('DateOfBirth');
$claimsForTokenConfigurationArray []= $claimsForTokenConfigurationOnTokenIssuanceStartReturnClaim1;
$claimsForTokenConfigurationOnTokenIssuanceStartReturnClaim2 = new OnTokenIssuanceStartReturnClaim();
$claimsForTokenConfigurationOnTokenIssuanceStartReturnClaim2->setClaimIdInApiResponse('CustomRoles');
$claimsForTokenConfigurationArray []= $claimsForTokenConfigurationOnTokenIssuanceStartReturnClaim2;
$requestBody->setClaimsForTokenConfiguration($claimsForTokenConfigurationArray);
$result = $graphServiceClient->identity()->customAuthenticationExtensions()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.SignIns
$params = @{
"@odata.type" = "#microsoft.graph.onTokenIssuanceStartCustomExtension"
displayName = "onTokenIssuanceStartCustomExtension"
description = "Fetch additional claims from custom user store"
endpointConfiguration = @{
"@odata.type" = "#microsoft.graph.httpRequestEndpoint"
targetUrl = "https://authenticationeventsAPI.contoso.com"
}
authenticationConfiguration = @{
"@odata.type" = "#microsoft.graph.azureAdTokenAuthentication"
resourceId = "api://authenticationeventsAPI.contoso.com/a13d0fc1-04ab-4ede-b215-63de0174cbb4"
}
clientConfiguration = @{
timeoutInMilliseconds = 2000
maximumRetries = 1
}
claimsForTokenConfiguration = @(
@{
claimIdInApiResponse = "DateOfBirth"
}
@{
claimIdInApiResponse = "CustomRoles"
}
)
}
New-MgBetaIdentityCustomAuthenticationExtension -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.on_token_issuance_start_custom_extension import OnTokenIssuanceStartCustomExtension
from msgraph_beta.generated.models.http_request_endpoint import HttpRequestEndpoint
from msgraph_beta.generated.models.azure_ad_token_authentication import AzureAdTokenAuthentication
from msgraph_beta.generated.models.custom_extension_client_configuration import CustomExtensionClientConfiguration
from msgraph_beta.generated.models.on_token_issuance_start_return_claim import OnTokenIssuanceStartReturnClaim
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = OnTokenIssuanceStartCustomExtension(
odata_type = "#microsoft.graph.onTokenIssuanceStartCustomExtension",
display_name = "onTokenIssuanceStartCustomExtension",
description = "Fetch additional claims from custom user store",
endpoint_configuration = HttpRequestEndpoint(
odata_type = "#microsoft.graph.httpRequestEndpoint",
target_url = "https://authenticationeventsAPI.contoso.com",
),
authentication_configuration = AzureAdTokenAuthentication(
odata_type = "#microsoft.graph.azureAdTokenAuthentication",
resource_id = "api://authenticationeventsAPI.contoso.com/a13d0fc1-04ab-4ede-b215-63de0174cbb4",
),
client_configuration = CustomExtensionClientConfiguration(
timeout_in_milliseconds = 2000,
maximum_retries = 1,
),
claims_for_token_configuration = [
OnTokenIssuanceStartReturnClaim(
claim_id_in_api_response = "DateOfBirth",
),
OnTokenIssuanceStartReturnClaim(
claim_id_in_api_response = "CustomRoles",
),
],
)
result = await graph_client.identity.custom_authentication_extensions.post(request_body)
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#identity/customAuthenticationExtensions/$entity",
"@odata.type": "#microsoft.graph.onTokenIssuanceStartCustomExtension",
"id": "6fc5012e-7665-43d6-9708-4370863f4e6e",
"displayName": "onTokenIssuanceStartCustomExtension",
"description": "Fetch additional claims from custom user store",
"clientConfiguration": null,
"behaviorOnError": null,
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",
"resourceId": "api://authenticationeventsAPI.contoso.com/a13d0fc1-04ab-4ede-b215-63de0174cbb4"
},
"clientConfiguration": {
"timeoutInMilliseconds": 2000,
"maximumRetries": 1
},
"endpointConfiguration": {
"@odata.type": "#microsoft.graph.httpRequestEndpoint",
"targetUrl": "https://authenticationeventsAPI.contoso.com"
},
"claimsForTokenConfiguration": [
{
"claimIdInApiResponse": "DateOfBirth"
},
{
"claimIdInApiResponse": "CustomRoles"
}
]
}
示例 2:创建 onAttributeCollectionStartCustomExtension 对象
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/beta/identity/customAuthenticationExtensions
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.onAttributeCollectionStartCustomExtension",
"displayName": "attributeCollectionStartName",
"description": "example description",
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",
"resourceId": "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e"
},
"endpointConfiguration": {
"@odata.type": "#microsoft.graph.httpRequestEndpoint",
"targetUrl": "https://contoso.com"
},
"clientConfiguration": {
"timeoutInMilliseconds": 2000,
"maximumRetries": 1
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new OnAttributeCollectionStartCustomExtension
{
OdataType = "#microsoft.graph.onAttributeCollectionStartCustomExtension",
DisplayName = "attributeCollectionStartName",
Description = "example description",
AuthenticationConfiguration = new AzureAdTokenAuthentication
{
OdataType = "#microsoft.graph.azureAdTokenAuthentication",
ResourceId = "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e",
},
EndpointConfiguration = new HttpRequestEndpoint
{
OdataType = "#microsoft.graph.httpRequestEndpoint",
TargetUrl = "https://contoso.com",
},
ClientConfiguration = new CustomExtensionClientConfiguration
{
TimeoutInMilliseconds = 2000,
MaximumRetries = 1,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Identity.CustomAuthenticationExtensions.PostAsync(requestBody);
mgc-beta identity custom-authentication-extensions create --body '{\
"@odata.type": "#microsoft.graph.onAttributeCollectionStartCustomExtension",\
"displayName": "attributeCollectionStartName",\
"description": "example description",\
"authenticationConfiguration": {\
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",\
"resourceId": "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e"\
},\
"endpointConfiguration": {\
"@odata.type": "#microsoft.graph.httpRequestEndpoint",\
"targetUrl": "https://contoso.com"\
},\
"clientConfiguration": {\
"timeoutInMilliseconds": 2000,\
"maximumRetries": 1\
}\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewCustomAuthenticationExtension()
displayName := "attributeCollectionStartName"
requestBody.SetDisplayName(&displayName)
description := "example description"
requestBody.SetDescription(&description)
authenticationConfiguration := graphmodels.NewAzureAdTokenAuthentication()
resourceId := "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e"
authenticationConfiguration.SetResourceId(&resourceId)
requestBody.SetAuthenticationConfiguration(authenticationConfiguration)
endpointConfiguration := graphmodels.NewHttpRequestEndpoint()
targetUrl := "https://contoso.com"
endpointConfiguration.SetTargetUrl(&targetUrl)
requestBody.SetEndpointConfiguration(endpointConfiguration)
clientConfiguration := graphmodels.NewCustomExtensionClientConfiguration()
timeoutInMilliseconds := int32(2000)
clientConfiguration.SetTimeoutInMilliseconds(&timeoutInMilliseconds)
maximumRetries := int32(1)
clientConfiguration.SetMaximumRetries(&maximumRetries)
requestBody.SetClientConfiguration(clientConfiguration)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
customAuthenticationExtensions, err := graphClient.Identity().CustomAuthenticationExtensions().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
OnAttributeCollectionStartCustomExtension customAuthenticationExtension = new OnAttributeCollectionStartCustomExtension();
customAuthenticationExtension.setOdataType("#microsoft.graph.onAttributeCollectionStartCustomExtension");
customAuthenticationExtension.setDisplayName("attributeCollectionStartName");
customAuthenticationExtension.setDescription("example description");
AzureAdTokenAuthentication authenticationConfiguration = new AzureAdTokenAuthentication();
authenticationConfiguration.setOdataType("#microsoft.graph.azureAdTokenAuthentication");
authenticationConfiguration.setResourceId("api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e");
customAuthenticationExtension.setAuthenticationConfiguration(authenticationConfiguration);
HttpRequestEndpoint endpointConfiguration = new HttpRequestEndpoint();
endpointConfiguration.setOdataType("#microsoft.graph.httpRequestEndpoint");
endpointConfiguration.setTargetUrl("https://contoso.com");
customAuthenticationExtension.setEndpointConfiguration(endpointConfiguration);
CustomExtensionClientConfiguration clientConfiguration = new CustomExtensionClientConfiguration();
clientConfiguration.setTimeoutInMilliseconds(2000);
clientConfiguration.setMaximumRetries(1);
customAuthenticationExtension.setClientConfiguration(clientConfiguration);
CustomAuthenticationExtension result = graphClient.identity().customAuthenticationExtensions().post(customAuthenticationExtension);
const options = {
authProvider,
};
const client = Client.init(options);
const customAuthenticationExtension = {
'@odata.type': '#microsoft.graph.onAttributeCollectionStartCustomExtension',
displayName: 'attributeCollectionStartName',
description: 'example description',
authenticationConfiguration: {
'@odata.type': '#microsoft.graph.azureAdTokenAuthentication',
resourceId: 'api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e'
},
endpointConfiguration: {
'@odata.type': '#microsoft.graph.httpRequestEndpoint',
targetUrl: 'https://contoso.com'
},
clientConfiguration: {
timeoutInMilliseconds: 2000,
maximumRetries: 1
}
};
await client.api('/identity/customAuthenticationExtensions')
.version('beta')
.post(customAuthenticationExtension);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\OnAttributeCollectionStartCustomExtension;
use Microsoft\Graph\Beta\Generated\Models\AzureAdTokenAuthentication;
use Microsoft\Graph\Beta\Generated\Models\HttpRequestEndpoint;
use Microsoft\Graph\Beta\Generated\Models\CustomExtensionClientConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new OnAttributeCollectionStartCustomExtension();
$requestBody->setOdataType('#microsoft.graph.onAttributeCollectionStartCustomExtension');
$requestBody->setDisplayName('attributeCollectionStartName');
$requestBody->setDescription('example description');
$authenticationConfiguration = new AzureAdTokenAuthentication();
$authenticationConfiguration->setOdataType('#microsoft.graph.azureAdTokenAuthentication');
$authenticationConfiguration->setResourceId('api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e');
$requestBody->setAuthenticationConfiguration($authenticationConfiguration);
$endpointConfiguration = new HttpRequestEndpoint();
$endpointConfiguration->setOdataType('#microsoft.graph.httpRequestEndpoint');
$endpointConfiguration->setTargetUrl('https://contoso.com');
$requestBody->setEndpointConfiguration($endpointConfiguration);
$clientConfiguration = new CustomExtensionClientConfiguration();
$clientConfiguration->setTimeoutInMilliseconds(2000);
$clientConfiguration->setMaximumRetries(1);
$requestBody->setClientConfiguration($clientConfiguration);
$result = $graphServiceClient->identity()->customAuthenticationExtensions()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.SignIns
$params = @{
"@odata.type" = "#microsoft.graph.onAttributeCollectionStartCustomExtension"
displayName = "attributeCollectionStartName"
description = "example description"
authenticationConfiguration = @{
"@odata.type" = "#microsoft.graph.azureAdTokenAuthentication"
resourceId = "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e"
}
endpointConfiguration = @{
"@odata.type" = "#microsoft.graph.httpRequestEndpoint"
targetUrl = "https://contoso.com"
}
clientConfiguration = @{
timeoutInMilliseconds = 2000
maximumRetries = 1
}
}
New-MgBetaIdentityCustomAuthenticationExtension -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.on_attribute_collection_start_custom_extension import OnAttributeCollectionStartCustomExtension
from msgraph_beta.generated.models.azure_ad_token_authentication import AzureAdTokenAuthentication
from msgraph_beta.generated.models.http_request_endpoint import HttpRequestEndpoint
from msgraph_beta.generated.models.custom_extension_client_configuration import CustomExtensionClientConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = OnAttributeCollectionStartCustomExtension(
odata_type = "#microsoft.graph.onAttributeCollectionStartCustomExtension",
display_name = "attributeCollectionStartName",
description = "example description",
authentication_configuration = AzureAdTokenAuthentication(
odata_type = "#microsoft.graph.azureAdTokenAuthentication",
resource_id = "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e",
),
endpoint_configuration = HttpRequestEndpoint(
odata_type = "#microsoft.graph.httpRequestEndpoint",
target_url = "https://contoso.com",
),
client_configuration = CustomExtensionClientConfiguration(
timeout_in_milliseconds = 2000,
maximum_retries = 1,
),
)
result = await graph_client.identity.custom_authentication_extensions.post(request_body)
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#identity/customAuthenticationExtensions/$entity",
"@odata.type": "#microsoft.graph.onAttributeCollectionStartCustomExtension",
"id": "2d9c3e8d-88a9-444e-8c4c-f0c6c4fe1c02",
"displayName": "attributeCollectionStartName",
"description": "example description",
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",
"resourceId": "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e"
},
"endpointConfiguration": {
"@odata.type": "#microsoft.graph.httpRequestEndpoint",
"targetUrl": "https://contoso.com"
},
"clientConfiguration": {
"timeoutInMilliseconds": 2000,
"maximumRetries": 1
}
}
示例 3:创建 onAttributeCollectionSubmitCustomExtension 对象
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/beta/identity/customAuthenticationExtensions
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.onAttributeCollectionSubmitCustomExtension",
"displayName": "attributeCollectionSubmitName",
"description": "example description",
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",
"resourceId": "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e"
},
"endpointConfiguration": {
"@odata.type": "#microsoft.graph.httpRequestEndpoint",
"targetUrl": "https://contoso.com"
},
"clientConfiguration": {
"timeoutInMilliseconds": 2000,
"maximumRetries": 1
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new OnAttributeCollectionSubmitCustomExtension
{
OdataType = "#microsoft.graph.onAttributeCollectionSubmitCustomExtension",
DisplayName = "attributeCollectionSubmitName",
Description = "example description",
AuthenticationConfiguration = new AzureAdTokenAuthentication
{
OdataType = "#microsoft.graph.azureAdTokenAuthentication",
ResourceId = "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e",
},
EndpointConfiguration = new HttpRequestEndpoint
{
OdataType = "#microsoft.graph.httpRequestEndpoint",
TargetUrl = "https://contoso.com",
},
ClientConfiguration = new CustomExtensionClientConfiguration
{
TimeoutInMilliseconds = 2000,
MaximumRetries = 1,
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Identity.CustomAuthenticationExtensions.PostAsync(requestBody);
mgc-beta identity custom-authentication-extensions create --body '{\
"@odata.type": "#microsoft.graph.onAttributeCollectionSubmitCustomExtension",\
"displayName": "attributeCollectionSubmitName",\
"description": "example description",\
"authenticationConfiguration": {\
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",\
"resourceId": "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e"\
},\
"endpointConfiguration": {\
"@odata.type": "#microsoft.graph.httpRequestEndpoint",\
"targetUrl": "https://contoso.com"\
},\
"clientConfiguration": {\
"timeoutInMilliseconds": 2000,\
"maximumRetries": 1\
}\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewCustomAuthenticationExtension()
displayName := "attributeCollectionSubmitName"
requestBody.SetDisplayName(&displayName)
description := "example description"
requestBody.SetDescription(&description)
authenticationConfiguration := graphmodels.NewAzureAdTokenAuthentication()
resourceId := "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e"
authenticationConfiguration.SetResourceId(&resourceId)
requestBody.SetAuthenticationConfiguration(authenticationConfiguration)
endpointConfiguration := graphmodels.NewHttpRequestEndpoint()
targetUrl := "https://contoso.com"
endpointConfiguration.SetTargetUrl(&targetUrl)
requestBody.SetEndpointConfiguration(endpointConfiguration)
clientConfiguration := graphmodels.NewCustomExtensionClientConfiguration()
timeoutInMilliseconds := int32(2000)
clientConfiguration.SetTimeoutInMilliseconds(&timeoutInMilliseconds)
maximumRetries := int32(1)
clientConfiguration.SetMaximumRetries(&maximumRetries)
requestBody.SetClientConfiguration(clientConfiguration)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
customAuthenticationExtensions, err := graphClient.Identity().CustomAuthenticationExtensions().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
OnAttributeCollectionSubmitCustomExtension customAuthenticationExtension = new OnAttributeCollectionSubmitCustomExtension();
customAuthenticationExtension.setOdataType("#microsoft.graph.onAttributeCollectionSubmitCustomExtension");
customAuthenticationExtension.setDisplayName("attributeCollectionSubmitName");
customAuthenticationExtension.setDescription("example description");
AzureAdTokenAuthentication authenticationConfiguration = new AzureAdTokenAuthentication();
authenticationConfiguration.setOdataType("#microsoft.graph.azureAdTokenAuthentication");
authenticationConfiguration.setResourceId("api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e");
customAuthenticationExtension.setAuthenticationConfiguration(authenticationConfiguration);
HttpRequestEndpoint endpointConfiguration = new HttpRequestEndpoint();
endpointConfiguration.setOdataType("#microsoft.graph.httpRequestEndpoint");
endpointConfiguration.setTargetUrl("https://contoso.com");
customAuthenticationExtension.setEndpointConfiguration(endpointConfiguration);
CustomExtensionClientConfiguration clientConfiguration = new CustomExtensionClientConfiguration();
clientConfiguration.setTimeoutInMilliseconds(2000);
clientConfiguration.setMaximumRetries(1);
customAuthenticationExtension.setClientConfiguration(clientConfiguration);
CustomAuthenticationExtension result = graphClient.identity().customAuthenticationExtensions().post(customAuthenticationExtension);
const options = {
authProvider,
};
const client = Client.init(options);
const customAuthenticationExtension = {
'@odata.type': '#microsoft.graph.onAttributeCollectionSubmitCustomExtension',
displayName: 'attributeCollectionSubmitName',
description: 'example description',
authenticationConfiguration: {
'@odata.type': '#microsoft.graph.azureAdTokenAuthentication',
resourceId: 'api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e'
},
endpointConfiguration: {
'@odata.type': '#microsoft.graph.httpRequestEndpoint',
targetUrl: 'https://contoso.com'
},
clientConfiguration: {
timeoutInMilliseconds: 2000,
maximumRetries: 1
}
};
await client.api('/identity/customAuthenticationExtensions')
.version('beta')
.post(customAuthenticationExtension);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\OnAttributeCollectionSubmitCustomExtension;
use Microsoft\Graph\Beta\Generated\Models\AzureAdTokenAuthentication;
use Microsoft\Graph\Beta\Generated\Models\HttpRequestEndpoint;
use Microsoft\Graph\Beta\Generated\Models\CustomExtensionClientConfiguration;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new OnAttributeCollectionSubmitCustomExtension();
$requestBody->setOdataType('#microsoft.graph.onAttributeCollectionSubmitCustomExtension');
$requestBody->setDisplayName('attributeCollectionSubmitName');
$requestBody->setDescription('example description');
$authenticationConfiguration = new AzureAdTokenAuthentication();
$authenticationConfiguration->setOdataType('#microsoft.graph.azureAdTokenAuthentication');
$authenticationConfiguration->setResourceId('api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e');
$requestBody->setAuthenticationConfiguration($authenticationConfiguration);
$endpointConfiguration = new HttpRequestEndpoint();
$endpointConfiguration->setOdataType('#microsoft.graph.httpRequestEndpoint');
$endpointConfiguration->setTargetUrl('https://contoso.com');
$requestBody->setEndpointConfiguration($endpointConfiguration);
$clientConfiguration = new CustomExtensionClientConfiguration();
$clientConfiguration->setTimeoutInMilliseconds(2000);
$clientConfiguration->setMaximumRetries(1);
$requestBody->setClientConfiguration($clientConfiguration);
$result = $graphServiceClient->identity()->customAuthenticationExtensions()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.SignIns
$params = @{
"@odata.type" = "#microsoft.graph.onAttributeCollectionSubmitCustomExtension"
displayName = "attributeCollectionSubmitName"
description = "example description"
authenticationConfiguration = @{
"@odata.type" = "#microsoft.graph.azureAdTokenAuthentication"
resourceId = "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e"
}
endpointConfiguration = @{
"@odata.type" = "#microsoft.graph.httpRequestEndpoint"
targetUrl = "https://contoso.com"
}
clientConfiguration = @{
timeoutInMilliseconds = 2000
maximumRetries = 1
}
}
New-MgBetaIdentityCustomAuthenticationExtension -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.on_attribute_collection_submit_custom_extension import OnAttributeCollectionSubmitCustomExtension
from msgraph_beta.generated.models.azure_ad_token_authentication import AzureAdTokenAuthentication
from msgraph_beta.generated.models.http_request_endpoint import HttpRequestEndpoint
from msgraph_beta.generated.models.custom_extension_client_configuration import CustomExtensionClientConfiguration
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = OnAttributeCollectionSubmitCustomExtension(
odata_type = "#microsoft.graph.onAttributeCollectionSubmitCustomExtension",
display_name = "attributeCollectionSubmitName",
description = "example description",
authentication_configuration = AzureAdTokenAuthentication(
odata_type = "#microsoft.graph.azureAdTokenAuthentication",
resource_id = "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e",
),
endpoint_configuration = HttpRequestEndpoint(
odata_type = "#microsoft.graph.httpRequestEndpoint",
target_url = "https://contoso.com",
),
client_configuration = CustomExtensionClientConfiguration(
timeout_in_milliseconds = 2000,
maximum_retries = 1,
),
)
result = await graph_client.identity.custom_authentication_extensions.post(request_body)
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/beta/$metadata#identity/customAuthenticationExtensions/$entity",
"@odata.type": "#microsoft.graph.onAttributeCollectionSubmitCustomExtension",
"id": "66867d1f-7824-4f38-aad1-75da1ad09ee2",
"displayName": "attributeCollectionSubmitName",
"description": "example description",
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",
"resourceId": "api://contoso.com/fb96de85-2abe-4b02-b45f-64ba122c509e"
},
"endpointConfiguration": {
"@odata.type": "#microsoft.graph.httpRequestEndpoint",
"targetUrl": "https://contoso.com"
},
"clientConfiguration": {
"timeoutInMilliseconds": 2000,
"maximumRetries": 1
}
}
示例 4:创建 onOtpSendCustomExtension 对象
请求
以下示例显示了一个请求。
POST https://graph.microsoft.com/beta/identity/customAuthenticationExtensions
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.onOtpSendCustomExtension",
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",
"resourceId": "api://onotpsendcustomextension.b2c.expert/fb96de85-2abe-4b02-b45f-64ba122c509e"
},
"clientConfiguration": {
"timeoutInMilliseconds": 2000,
"maximumRetries": 1
},
"description": "Use an external Email provider to send OTP Codes.",
"displayName": "onEmailOtpSendCustomExtension",
"endpointConfiguration": {
"@odata.type": "#microsoft.graph.httpRequestEndpoint",
"targetUrl": "https://onotpsendcustomextension.b2c.expert/api/OnOTPCodeSendToTeamsDemo"
},
"behaviorOnError": {
"@odata.type": "microsoft.graph.customExtensionBehaviorOnError"
}
}
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Beta.Models;
var requestBody = new OnOtpSendCustomExtension
{
OdataType = "#microsoft.graph.onOtpSendCustomExtension",
AuthenticationConfiguration = new AzureAdTokenAuthentication
{
OdataType = "#microsoft.graph.azureAdTokenAuthentication",
ResourceId = "api://onotpsendcustomextension.b2c.expert/fb96de85-2abe-4b02-b45f-64ba122c509e",
},
ClientConfiguration = new CustomExtensionClientConfiguration
{
TimeoutInMilliseconds = 2000,
MaximumRetries = 1,
},
Description = "Use an external Email provider to send OTP Codes.",
DisplayName = "onEmailOtpSendCustomExtension",
EndpointConfiguration = new HttpRequestEndpoint
{
OdataType = "#microsoft.graph.httpRequestEndpoint",
TargetUrl = "https://onotpsendcustomextension.b2c.expert/api/OnOTPCodeSendToTeamsDemo",
},
BehaviorOnError = new CustomExtensionBehaviorOnError
{
OdataType = "microsoft.graph.customExtensionBehaviorOnError",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Identity.CustomAuthenticationExtensions.PostAsync(requestBody);
mgc-beta identity custom-authentication-extensions create --body '{\
"@odata.type": "#microsoft.graph.onOtpSendCustomExtension",\
"authenticationConfiguration": {\
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",\
"resourceId": "api://onotpsendcustomextension.b2c.expert/fb96de85-2abe-4b02-b45f-64ba122c509e"\
},\
"clientConfiguration": {\
"timeoutInMilliseconds": 2000,\
"maximumRetries": 1\
},\
"description": "Use an external Email provider to send OTP Codes.",\
"displayName": "onEmailOtpSendCustomExtension",\
"endpointConfiguration": {\
"@odata.type": "#microsoft.graph.httpRequestEndpoint",\
"targetUrl": "https://onotpsendcustomextension.b2c.expert/api/OnOTPCodeSendToTeamsDemo"\
},\
"behaviorOnError": {\
"@odata.type": "microsoft.graph.customExtensionBehaviorOnError"\
}\
}\
'
// Code snippets are only available for the latest major version. Current major version is $v0.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-beta-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-beta-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewCustomAuthenticationExtension()
authenticationConfiguration := graphmodels.NewAzureAdTokenAuthentication()
resourceId := "api://onotpsendcustomextension.b2c.expert/fb96de85-2abe-4b02-b45f-64ba122c509e"
authenticationConfiguration.SetResourceId(&resourceId)
requestBody.SetAuthenticationConfiguration(authenticationConfiguration)
clientConfiguration := graphmodels.NewCustomExtensionClientConfiguration()
timeoutInMilliseconds := int32(2000)
clientConfiguration.SetTimeoutInMilliseconds(&timeoutInMilliseconds)
maximumRetries := int32(1)
clientConfiguration.SetMaximumRetries(&maximumRetries)
requestBody.SetClientConfiguration(clientConfiguration)
description := "Use an external Email provider to send OTP Codes."
requestBody.SetDescription(&description)
displayName := "onEmailOtpSendCustomExtension"
requestBody.SetDisplayName(&displayName)
endpointConfiguration := graphmodels.NewHttpRequestEndpoint()
targetUrl := "https://onotpsendcustomextension.b2c.expert/api/OnOTPCodeSendToTeamsDemo"
endpointConfiguration.SetTargetUrl(&targetUrl)
requestBody.SetEndpointConfiguration(endpointConfiguration)
behaviorOnError := graphmodels.NewCustomExtensionBehaviorOnError()
requestBody.SetBehaviorOnError(behaviorOnError)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
customAuthenticationExtensions, err := graphClient.Identity().CustomAuthenticationExtensions().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
OnOtpSendCustomExtension customAuthenticationExtension = new OnOtpSendCustomExtension();
customAuthenticationExtension.setOdataType("#microsoft.graph.onOtpSendCustomExtension");
AzureAdTokenAuthentication authenticationConfiguration = new AzureAdTokenAuthentication();
authenticationConfiguration.setOdataType("#microsoft.graph.azureAdTokenAuthentication");
authenticationConfiguration.setResourceId("api://onotpsendcustomextension.b2c.expert/fb96de85-2abe-4b02-b45f-64ba122c509e");
customAuthenticationExtension.setAuthenticationConfiguration(authenticationConfiguration);
CustomExtensionClientConfiguration clientConfiguration = new CustomExtensionClientConfiguration();
clientConfiguration.setTimeoutInMilliseconds(2000);
clientConfiguration.setMaximumRetries(1);
customAuthenticationExtension.setClientConfiguration(clientConfiguration);
customAuthenticationExtension.setDescription("Use an external Email provider to send OTP Codes.");
customAuthenticationExtension.setDisplayName("onEmailOtpSendCustomExtension");
HttpRequestEndpoint endpointConfiguration = new HttpRequestEndpoint();
endpointConfiguration.setOdataType("#microsoft.graph.httpRequestEndpoint");
endpointConfiguration.setTargetUrl("https://onotpsendcustomextension.b2c.expert/api/OnOTPCodeSendToTeamsDemo");
customAuthenticationExtension.setEndpointConfiguration(endpointConfiguration);
CustomExtensionBehaviorOnError behaviorOnError = new CustomExtensionBehaviorOnError();
behaviorOnError.setOdataType("microsoft.graph.customExtensionBehaviorOnError");
customAuthenticationExtension.setBehaviorOnError(behaviorOnError);
CustomAuthenticationExtension result = graphClient.identity().customAuthenticationExtensions().post(customAuthenticationExtension);
const options = {
authProvider,
};
const client = Client.init(options);
const customAuthenticationExtension = {
'@odata.type': '#microsoft.graph.onOtpSendCustomExtension',
authenticationConfiguration: {
'@odata.type': '#microsoft.graph.azureAdTokenAuthentication',
resourceId: 'api://onotpsendcustomextension.b2c.expert/fb96de85-2abe-4b02-b45f-64ba122c509e'
},
clientConfiguration: {
timeoutInMilliseconds: 2000,
maximumRetries: 1
},
description: 'Use an external Email provider to send OTP Codes.',
displayName: 'onEmailOtpSendCustomExtension',
endpointConfiguration: {
'@odata.type': '#microsoft.graph.httpRequestEndpoint',
targetUrl: 'https://onotpsendcustomextension.b2c.expert/api/OnOTPCodeSendToTeamsDemo'
},
behaviorOnError: {
'@odata.type': 'microsoft.graph.customExtensionBehaviorOnError'
}
};
await client.api('/identity/customAuthenticationExtensions')
.version('beta')
.post(customAuthenticationExtension);
<?php
use Microsoft\Graph\Beta\GraphServiceClient;
use Microsoft\Graph\Beta\Generated\Models\OnOtpSendCustomExtension;
use Microsoft\Graph\Beta\Generated\Models\AzureAdTokenAuthentication;
use Microsoft\Graph\Beta\Generated\Models\CustomExtensionClientConfiguration;
use Microsoft\Graph\Beta\Generated\Models\HttpRequestEndpoint;
use Microsoft\Graph\Beta\Generated\Models\CustomExtensionBehaviorOnError;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new OnOtpSendCustomExtension();
$requestBody->setOdataType('#microsoft.graph.onOtpSendCustomExtension');
$authenticationConfiguration = new AzureAdTokenAuthentication();
$authenticationConfiguration->setOdataType('#microsoft.graph.azureAdTokenAuthentication');
$authenticationConfiguration->setResourceId('api://onotpsendcustomextension.b2c.expert/fb96de85-2abe-4b02-b45f-64ba122c509e');
$requestBody->setAuthenticationConfiguration($authenticationConfiguration);
$clientConfiguration = new CustomExtensionClientConfiguration();
$clientConfiguration->setTimeoutInMilliseconds(2000);
$clientConfiguration->setMaximumRetries(1);
$requestBody->setClientConfiguration($clientConfiguration);
$requestBody->setDescription('Use an external Email provider to send OTP Codes.');
$requestBody->setDisplayName('onEmailOtpSendCustomExtension');
$endpointConfiguration = new HttpRequestEndpoint();
$endpointConfiguration->setOdataType('#microsoft.graph.httpRequestEndpoint');
$endpointConfiguration->setTargetUrl('https://onotpsendcustomextension.b2c.expert/api/OnOTPCodeSendToTeamsDemo');
$requestBody->setEndpointConfiguration($endpointConfiguration);
$behaviorOnError = new CustomExtensionBehaviorOnError();
$behaviorOnError->setOdataType('microsoft.graph.customExtensionBehaviorOnError');
$requestBody->setBehaviorOnError($behaviorOnError);
$result = $graphServiceClient->identity()->customAuthenticationExtensions()->post($requestBody)->wait();
Import-Module Microsoft.Graph.Beta.Identity.SignIns
$params = @{
"@odata.type" = "#microsoft.graph.onOtpSendCustomExtension"
authenticationConfiguration = @{
"@odata.type" = "#microsoft.graph.azureAdTokenAuthentication"
resourceId = "api://onotpsendcustomextension.b2c.expert/fb96de85-2abe-4b02-b45f-64ba122c509e"
}
clientConfiguration = @{
timeoutInMilliseconds = 2000
maximumRetries = 1
}
description = "Use an external Email provider to send OTP Codes."
displayName = "onEmailOtpSendCustomExtension"
endpointConfiguration = @{
"@odata.type" = "#microsoft.graph.httpRequestEndpoint"
targetUrl = "https://onotpsendcustomextension.b2c.expert/api/OnOTPCodeSendToTeamsDemo"
}
behaviorOnError = @{
"@odata.type" = "microsoft.graph.customExtensionBehaviorOnError"
}
}
New-MgBetaIdentityCustomAuthenticationExtension -BodyParameter $params
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph_beta import GraphServiceClient
from msgraph_beta.generated.models.on_otp_send_custom_extension import OnOtpSendCustomExtension
from msgraph_beta.generated.models.azure_ad_token_authentication import AzureAdTokenAuthentication
from msgraph_beta.generated.models.custom_extension_client_configuration import CustomExtensionClientConfiguration
from msgraph_beta.generated.models.http_request_endpoint import HttpRequestEndpoint
from msgraph_beta.generated.models.custom_extension_behavior_on_error import CustomExtensionBehaviorOnError
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = OnOtpSendCustomExtension(
odata_type = "#microsoft.graph.onOtpSendCustomExtension",
authentication_configuration = AzureAdTokenAuthentication(
odata_type = "#microsoft.graph.azureAdTokenAuthentication",
resource_id = "api://onotpsendcustomextension.b2c.expert/fb96de85-2abe-4b02-b45f-64ba122c509e",
),
client_configuration = CustomExtensionClientConfiguration(
timeout_in_milliseconds = 2000,
maximum_retries = 1,
),
description = "Use an external Email provider to send OTP Codes.",
display_name = "onEmailOtpSendCustomExtension",
endpoint_configuration = HttpRequestEndpoint(
odata_type = "#microsoft.graph.httpRequestEndpoint",
target_url = "https://onotpsendcustomextension.b2c.expert/api/OnOTPCodeSendToTeamsDemo",
),
behavior_on_error = CustomExtensionBehaviorOnError(
odata_type = "microsoft.graph.customExtensionBehaviorOnError",
),
)
result = await graph_client.identity.custom_authentication_extensions.post(request_body)
响应
以下示例显示了相应的响应。
注意:为了提高可读性,可能缩短了此处显示的响应对象。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.onOtpSendCustomExtension",
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.azureAdTokenAuthentication",
"resourceId": "api://onotpsendcustomextension.b2c.expert/fb96de85-2abe-4b02-b45f-64ba122c509e"
},
"clientConfiguration": {
"timeoutInMilliseconds": 2000,
"maximumRetries": 1
},
"description": "Use an external Email provider to send OTP Codes.",
"displayName": "onEmailOtpSendCustomExtension",
"endpointConfiguration": {
"@odata.type": "#microsoft.graph.httpRequestEndpoint",
"targetUrl": "https://onotpsendcustomextension.b2c.expert/api/OnOTPCodeSendToTeamsDemo"
},
"behaviorOnError": {
"@odata.type": "microsoft.graph.customExtensionBehaviorOnError"
}
}