IdentityApiConnector の作成
-
[アーティクル]
-
-
名前空間: microsoft.graph
新しい identityApiConnector オブジェクトを作成 します。
アクセス許可
この API を呼び出すには、次のいずれかのアクセス許可が必要です。アクセス許可の選択方法などの詳細については、「アクセス許可」を参照してください。
| アクセス許可の種類 |
アクセス許可 (特権の小さいものから大きいものへ) |
| 委任 (職場または学校のアカウント) |
APIConnectors.ReadWrite.All |
| 委任 (個人用 Microsoft アカウント) |
サポートされていません。 |
| アプリケーション |
APIConnectors.ReadWrite.All |
仕事または学校のアカウントは、次のいずれかの役割に属している必要があります。
- グローバル管理者
- 外部 ID ユーザー Flow管理者
HTTP 要求
POST /identity/apiConnectors
| 名前 |
説明 |
| Authorization |
ベアラー {token}。必須。 |
| Content-Type |
application/json. Required. |
要求本文
要求本文で、 identityApiConnector オブジェクトの JSON 表記を指定 します。
次の表に、identityApiConnector を作成するときに必要な プロパティを示します。
応答
成功した場合、このメソッドは応答 201 Created コードと、応答本文 の identityApiConnector オブジェクトを返します。
例
例 1: 基本認証を使用して API コネクタを作成する
要求
要求の例を次に示します。
POST https://graph.microsoft.com/v1.0/identity/apiConnectors
Content-Type: application/json
{
"displayName":"Test API",
"targetUrl":"https://someapi.com/api",
"authenticationConfiguration": {
"@odata.type":"#microsoft.graph.basicAuthentication",
"username": "MyUsername",
"password": "MyPassword"
}
}
GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var identityApiConnector = new IdentityApiConnector
{
DisplayName = "Test API",
TargetUrl = "https://someotherapi.com/api",
AuthenticationConfiguration = new Pkcs12Certificate
{
Pkcs12Value = "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA",
Password = "CertificatePassword"
}
};
await graphClient.Identity.ApiConnectors
.Request()
.AddAsync(identityApiConnector);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
const options = {
authProvider,
};
const client = Client.init(options);
const identityApiConnector = {
displayName: 'Test API',
targetUrl: 'https://someotherapi.com/api',
authenticationConfiguration: {
'@odata.type':'#microsoft.graph.pkcs12Certificate',
pkcs12Value: 'eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA',
password: 'CertificatePassword'
}
};
await client.api('/identity/apiConnectors')
.post(identityApiConnector);
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/apiConnectors"]]];
[urlRequest setHTTPMethod:@"POST"];
[urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
MSGraphIdentityApiConnector *identityApiConnector = [[MSGraphIdentityApiConnector alloc] init];
[identityApiConnector setDisplayName:@"Test API"];
[identityApiConnector setTargetUrl:@"https://someotherapi.com/api"];
MSGraphApiAuthenticationConfigurationBase *authenticationConfiguration = [[MSGraphApiAuthenticationConfigurationBase alloc] init];
[authenticationConfiguration setPkcs12Value:@"eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA"];
[authenticationConfiguration setPassword:@"CertificatePassword"];
[identityApiConnector setAuthenticationConfiguration:authenticationConfiguration];
NSError *error;
NSData *identityApiConnectorData = [identityApiConnector getSerializedDataWithError:&error];
[urlRequest setHTTPBody:identityApiConnectorData];
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();
IdentityApiConnector identityApiConnector = new IdentityApiConnector();
identityApiConnector.displayName = "Test API";
identityApiConnector.targetUrl = "https://someotherapi.com/api";
Pkcs12Certificate authenticationConfiguration = new Pkcs12Certificate();
authenticationConfiguration.pkcs12Value = "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA";
authenticationConfiguration.password = "CertificatePassword";
identityApiConnector.authenticationConfiguration = authenticationConfiguration;
graphClient.identity().apiConnectors()
.buildRequest()
.post(identityApiConnector);
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
//THE GO SDK IS IN PREVIEW. NON-PRODUCTION USE ONLY
graphClient := msgraphsdk.NewGraphServiceClient(requestAdapter)
requestBody := msgraphsdk.NewIdentityApiConnector()
displayName := "Test API"
requestBody.SetDisplayName(&displayName)
targetUrl := "https://someotherapi.com/api"
requestBody.SetTargetUrl(&targetUrl)
authenticationConfiguration := msgraphsdk.NewApiAuthenticationConfigurationBase()
requestBody.SetAuthenticationConfiguration(authenticationConfiguration)
authenticationConfiguration.SetAdditionalData(map[string]interface{}{
"@odata.type": "#microsoft.graph.pkcs12Certificate",
"pkcs12Value": "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA",
"password": "CertificatePassword",
}
result, err := graphClient.Identity().ApiConnectors().Post(requestBody)
SDK をプロジェクトに追加し、authProvider インスタンスを作成する方法の詳細については、SDK のドキュメントを参照してください。
応答
応答の例を次に示します。
注: ここに示す応答オブジェクトは、読みやすさのために短縮されている場合があります。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#identity/apiConnectors/$entity",
"id":"45715bb8-13f9-4bf6-927f-ef96c102d394",
"displayName": "Test API",
"targetUrl": "https://someapi.com/api",
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.basicAuthentication",
"username": "MyUsername",
"password": "******"
}
}
例 2: クライアント証明書認証を使用して API コネクタを作成する
要求
要求の例を次に示します。
注: authenticationConfiguration 要求の種類は microsoft.graph.pkcs12certificate で、アップロードまたは作成に必要な証明書の構成を表します。
POST https://graph.microsoft.com/v1.0/identity/apiConnectors
Content-Type: application/json
{
"displayName":"Test API",
"targetUrl":"https://someotherapi.com/api",
"authenticationConfiguration": {
"@odata.type":"#microsoft.graph.pkcs12Certificate",
"pkcs12Value": "eyJhbGciOiJSU0EtT0FFUCIsImVuYyI6IkEyNTZHQ00ifQ...kDJ04sJShkkgjL9Bm49plA",
"password": "CertificatePassword"
}
}
応答
応答の例を次に示します。
注: authenticationConfiguration 応答の種類は microsoft.graph.clientCertificateAuthentication なので、アップロードされた証明書の公開情報を表します。
HTTP/1.1 201 Created
Content-Type: application/json
{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#identity/apiConnectors/$entity",
"id":"45715bb8-13f9-4bf6-927f-ef96c102d394",
"displayName": "Test API",
"targetUrl": "https://someotherapi.com/api",
"authenticationConfiguration": {
"@odata.type": "#microsoft.graph.clientCertificateAuthentication",
"certificateList": [
{
"thumbprint": "0EB255CC895477798BA418B378255204304897AD",
"notAfter": 1666350522,
"notBefore": 1508670522,
"isActive": true
}
]
}
}