カスタム コネクタの複数認証の追加

認証の種類が 1 つであるオプションに対して、複数認証 (multi-auth) は、接続に必要な認証方法をユーザーが選択できるオプションを提供する機能です。

コネクタの場合は、connectionParameterSets ファイル内のapiProperties.jsonを使用して認証の種類のコレクションを定義します。

重要

カスタム コネクタ ウィザードでは、カスタム コネクタで複数の認証を有効にすることはできません。 代わりに、Microsoft Power Platform コネクタ CLI を使用して、マルチ認証を使用してカスタム コネクタを作成します。

複数の認証を有効にする方法

connectionParameterSets ファイルで apiProperties.json を追加し、コネクタに必要な分の connectionParameterSets.values を使用してコレクション connectionParameters を設定します。

接続パラメーターと認証の種類の詳細については、「 接続パラメーター」を参照してください

重要

  • コネクタで OAuth を使用している場合は、期限切れのクライアント ID とクライアント シークレットの資格情報を定期的に監視して更新し、顧客がコネクタを引き続き使用できるようにします。
  • クライアント シークレットを更新する場合は、swagger バージョンを更新します。
  • クライアント ID とクライアント シークレットの有効期限が切れる 1 か月前に 、コネクタの更新プログラム を送信します。

uiDefinition-constraints-required: true は、パラメーターの下の認証の種類ごとに、 ConnectionsParameterSets ファイルの必須パラメーターです。

次のセクションでは、 connectionParameterSetsの構造を示します。

"connectionParameterSets": {
  // uiDefinition for the parameter sets.
  "uiDefinition": {
    "displayname": "Select the authorization type",
    "description": "<<Enter here your description>>"
  },
  "values": [
    // Connection parameter set
    {
      "name": "<parameter set name>",
      // uiDefinition for this parameter set.
      "uiDefinition": {
        "displayname": "<display name>",
        "description": "<description text>"
      },
      "parameters": {
        // Schema matches existing "connectionParameters"
        "<parameter name>": {
          "type": "string | securestring | oauthsetting"
        },
        "<parameter name>:clientId": {
          "type": "string",
          "uiDefinition": {
            "schema": {
              // For string types, the description must be placed in
              // uiDefinition.schema.description to be shown in the description box
              "type": "string",
              "description": "<description text>"
            },
            "displayName": "<display name>",
          }
        }
      }
    },
    {
      "name": "<parameter set name 2>"
      // ...
    }
  ]
}

API キーと基本認証のある構成

"connectionParameterSets": {
    "uiDefinition": {
        "displayName": "Authentication Type",
        "description": "Type of authentication to be used."
    },
    "values": [
        {
            "name": "basic-auth",
            "uiDefinition": {
                "displayName": "Use your X credentials",
                "description": "Log in using your username and password for X."
            },
            "parameters": {
                "username": {
                    "type": "string",
                    "uiDefinition": {
                        "displayName": "X username",
                        "schema":{
                            "description": "The username for X",
                            "type": "string"
                        },
                        "tooltip": "Provide your X username",
                        "constraints": {
                            "required": "true"
                        }
                    }
                },
                "password": {
                    "type": "securestring",
                    "uiDefinition": {
                        "displayName": "X password",
                        "schema":{
                            "description": "The password for X",
                            "type": "securestring"
                        },
                        "tooltip": "Provide your X password",
                        "constraints": {
                            "required": "true"
                        }
                    }
                }
            }
        },
        {
            "name": "api-auth",
            "uiDefinition": {
                "displayName": "Use X API Key",
                "description": "Log in using X's API Key."
            },
            "parameters": {
                "api_key": {
                    "type": "securestring",
                    "uiDefinition": {
                        "constraints": {
                            "clearText": false,
                            "required": "true",
                            "tabIndex": 3
                        },
                        "schema":{
                            "description": "Enter your API Key for X",
                            "type": "securestring"
                        },
                        "displayName": "API Key generated in X"
                    }
                },
                "environment": {
                    "type": "string",
                    "uiDefinition": {
                        "displayName": "Environment",
                        "schema":{
                            "description": "The API environment to use; either production or sandbox",
                            "type": "string"
                        },
                        "tooltip": "Select an API environment to use",
                        "constraints": {
                            "required": "true",
                            "allowedValues": [
                                {
                                    "text": "Sandbox",
                                    "value": "YOUR_SANDBOX_VALUE_HERE"
                                },
                                {
                                    "text": "Production",
                                    "value": "YOUR_PROD_VALUE_HERE"
                                }
                            ]
                        }
                    }
                }
            }
        }
    ]
}

Entra ID と OAuth 2.0 を使用した構成

同じ種類の 2 つの接続パラメーターを構成できます。 この場合、両方の権限で oauthSetting タイプが使用されます。 1 つの承認により、ユーザーは Entra ID を使用して接続を作成でき、もう 1 つの承認はカスタム エンドポイントに送信されます。

"connectionParameterSets": {
    "uiDefinition": {
        "displayName": "Authentication Type",
        "description": "Type of authentication to be used."
    },
    "values": [
        {
            "name": "aad-auth",
            "uiDefinition": {
                "displayName": "Use default shared application",
                "description": "Log in using the standard X app."
            },
            "parameters": {
                "token": {
                    "oAuthSettings": {
                        "clientId": "YOUR_AAD_APPLICATION_ID_HERE",
                        "customParameters": {
                            "loginUri": {
                                "value": "https://login.windows.net"
                            },
                            "resourceUri": {
                                "value": "https://graph.microsoft.com"
                            },
                            "tenantId": {
                                "value": "common"
                            }
                        },
                        "identityProvider": "aad",
                        "properties": {
                            "IsFirstParty": "False"
                        },
                        "redirectMode": "GlobalPerConnector",
                        "scopes": [
                            "Group.ReadWrite.All offline_access"
                        ]
                    },
                    "type": "oauthSetting",
                    "uiDefinition": {
                        "displayName": "AAD based authentication",
                        "description": "Sign in using your AAD credentials",
                        "tooltip": "AAD based authentication",
                        "constraints": {
                            "required": "true"
                        }
                    }
                }
            }
        },
        {
            "name": "custom-app-auth",
            "uiDefinition": {
                "displayName": "Use the X authentication app",
                "description": "Log in using X app."
            },
            "parameters": {
                "token": {
                    "type": "oauthSetting",
                    "oAuthSettings": {
                        "clientId": "YOUR_CLIENT_ID_HERE",
                        "identityProvider": "oauth2",
                        "redirectMode": "GlobalPerConnector",
                        "customParameters": {
                            "authorizationUrl": {
                                "value": "https://login.dummy.net/request"
                            },
                            "refreshUrl": {
                                "value": "https://login.dummy.net/token"
                            },
                            "tokenUrl": {
                                "value": "https://login.dummy.net/token"
                            }
                        }
                    },
                    "uiDefinition": {
                        "displayName": "Custom app based authentication",
                        "description": "Sign in using your custom app credentials",
                        "tooltip": "Custom app based authentication",
                        "constraints": {
                            "required": "true"
                        }
                    }
                }
            }
        }
    ]
}

RescoCloud コネクタでマルチ認証を実装する方法の例を見つけることができます。