Выберите разрешение или разрешения, помеченные как наименее привилегированные для этого API. Используйте более привилегированное разрешение или разрешения только в том случае, если это требуется приложению. Дополнительные сведения о делегированных разрешениях и разрешениях приложений см. в разделе Типы разрешений. Дополнительные сведения об этих разрешениях см. в справочнике по разрешениям.
Тип разрешения
Разрешения с наименьшими привилегиями
Более высокие привилегированные разрешения
Делегированные (рабочая или учебная учетная запись)
APIConnectors.ReadWrite.All
Недоступно.
Делегированные (личная учетная запись Майкрософт)
Не поддерживается.
Не поддерживается.
Приложение
APIConnectors.ReadWrite.All
Недоступно.
Важно!
В делегированных сценариях с рабочими или учебными учетными записями вошедшему пользователю должна быть назначена поддерживаемая роль Microsoft Entra или настраиваемая роль с разрешением поддерживаемой роли.
Внешняя идентификация администратор потока пользователей — это наименее привилегированная роль, поддерживаемая для этой операции.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new IdentityApiConnector
{
DisplayName = "Test API",
TargetUrl = "https://someapi.com/api",
AuthenticationConfiguration = new BasicAuthentication
{
OdataType = "#microsoft.graph.basicAuthentication",
Username = "MyUsername",
Password = "MyPassword",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Identity.ApiConnectors.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewIdentityApiConnector()
displayName := "Test API"
requestBody.SetDisplayName(&displayName)
targetUrl := "https://someapi.com/api"
requestBody.SetTargetUrl(&targetUrl)
authenticationConfiguration := graphmodels.NewBasicAuthentication()
username := "MyUsername"
authenticationConfiguration.SetUsername(&username)
password := "MyPassword"
authenticationConfiguration.SetPassword(&password)
requestBody.SetAuthenticationConfiguration(authenticationConfiguration)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
apiConnectors, err := graphClient.Identity().ApiConnectors().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
IdentityApiConnector identityApiConnector = new IdentityApiConnector();
identityApiConnector.setDisplayName("Test API");
identityApiConnector.setTargetUrl("https://someapi.com/api");
BasicAuthentication authenticationConfiguration = new BasicAuthentication();
authenticationConfiguration.setOdataType("#microsoft.graph.basicAuthentication");
authenticationConfiguration.setUsername("MyUsername");
authenticationConfiguration.setPassword("MyPassword");
identityApiConnector.setAuthenticationConfiguration(authenticationConfiguration);
IdentityApiConnector result = graphClient.identity().apiConnectors().post(identityApiConnector);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\IdentityApiConnector;
use Microsoft\Graph\Generated\Models\BasicAuthentication;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new IdentityApiConnector();
$requestBody->setDisplayName('Test API');
$requestBody->setTargetUrl('https://someapi.com/api');
$authenticationConfiguration = new BasicAuthentication();
$authenticationConfiguration->setOdataType('#microsoft.graph.basicAuthentication');
$authenticationConfiguration->setUsername('MyUsername');
$authenticationConfiguration->setPassword('MyPassword');
$requestBody->setAuthenticationConfiguration($authenticationConfiguration);
$result = $graphServiceClient->identity()->apiConnectors()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.identity_api_connector import IdentityApiConnector
from msgraph.generated.models.basic_authentication import BasicAuthentication
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = IdentityApiConnector(
display_name = "Test API",
target_url = "https://someapi.com/api",
authentication_configuration = BasicAuthentication(
odata_type = "#microsoft.graph.basicAuthentication",
username = "MyUsername",
password = "MyPassword",
),
)
result = await graph_client.identity.api_connectors.post(request_body)
Пример 2. Создание соединителя API с проверкой подлинности сертификата клиента
Запрос
Ниже показан пример запроса.
Заметка:authenticationConfiguration в запросе имеет тип microsoft.graph.pkcs12certificate, который представляет конфигурацию сертификата, необходимого для отправки или создания.
// Code snippets are only available for the latest version. Current version is 5.x
// Dependencies
using Microsoft.Graph.Models;
var requestBody = new IdentityApiConnector
{
DisplayName = "Test API",
TargetUrl = "https://someotherapi.com/api",
AuthenticationConfiguration = new Pkcs12Certificate
{
OdataType = "#microsoft.graph.pkcs12Certificate",
Pkcs12Value = "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA",
Password = "CertificatePassword",
},
};
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=csharp
var result = await graphClient.Identity.ApiConnectors.PostAsync(requestBody);
// Code snippets are only available for the latest major version. Current major version is $v1.*
// Dependencies
import (
"context"
msgraphsdk "github.com/microsoftgraph/msgraph-sdk-go"
graphmodels "github.com/microsoftgraph/msgraph-sdk-go/models"
//other-imports
)
requestBody := graphmodels.NewIdentityApiConnector()
displayName := "Test API"
requestBody.SetDisplayName(&displayName)
targetUrl := "https://someotherapi.com/api"
requestBody.SetTargetUrl(&targetUrl)
authenticationConfiguration := graphmodels.NewPkcs12Certificate()
pkcs12Value := "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA"
authenticationConfiguration.SetPkcs12Value(&pkcs12Value)
password := "CertificatePassword"
authenticationConfiguration.SetPassword(&password)
requestBody.SetAuthenticationConfiguration(authenticationConfiguration)
// To initialize your graphClient, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=go
apiConnectors, err := graphClient.Identity().ApiConnectors().Post(context.Background(), requestBody, nil)
// Code snippets are only available for the latest version. Current version is 6.x
GraphServiceClient graphClient = new GraphServiceClient(requestAdapter);
IdentityApiConnector identityApiConnector = new IdentityApiConnector();
identityApiConnector.setDisplayName("Test API");
identityApiConnector.setTargetUrl("https://someotherapi.com/api");
Pkcs12Certificate authenticationConfiguration = new Pkcs12Certificate();
authenticationConfiguration.setOdataType("#microsoft.graph.pkcs12Certificate");
authenticationConfiguration.setPkcs12Value("eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA");
authenticationConfiguration.setPassword("CertificatePassword");
identityApiConnector.setAuthenticationConfiguration(authenticationConfiguration);
IdentityApiConnector result = graphClient.identity().apiConnectors().post(identityApiConnector);
<?php
use Microsoft\Graph\GraphServiceClient;
use Microsoft\Graph\Generated\Models\IdentityApiConnector;
use Microsoft\Graph\Generated\Models\Pkcs12Certificate;
$graphServiceClient = new GraphServiceClient($tokenRequestContext, $scopes);
$requestBody = new IdentityApiConnector();
$requestBody->setDisplayName('Test API');
$requestBody->setTargetUrl('https://someotherapi.com/api');
$authenticationConfiguration = new Pkcs12Certificate();
$authenticationConfiguration->setOdataType('#microsoft.graph.pkcs12Certificate');
$authenticationConfiguration->setPkcs12Value('eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA');
$authenticationConfiguration->setPassword('CertificatePassword');
$requestBody->setAuthenticationConfiguration($authenticationConfiguration);
$result = $graphServiceClient->identity()->apiConnectors()->post($requestBody)->wait();
# Code snippets are only available for the latest version. Current version is 1.x
from msgraph import GraphServiceClient
from msgraph.generated.models.identity_api_connector import IdentityApiConnector
from msgraph.generated.models.pkcs12_certificate import Pkcs12Certificate
# To initialize your graph_client, see https://learn.microsoft.com/en-us/graph/sdks/create-client?from=snippets&tabs=python
request_body = IdentityApiConnector(
display_name = "Test API",
target_url = "https://someotherapi.com/api",
authentication_configuration = Pkcs12Certificate(
odata_type = "#microsoft.graph.pkcs12Certificate",
pkcs12_value = "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA",
password = "CertificatePassword",
),
)
result = await graph_client.identity.api_connectors.post(request_body)