It appears that creating a custom connector in PowerApps using client certificate authentication is not straightforward, as the option might not be readily visible in the security tab of the custom connector settings. Here is an end-to-end guide to help you set up client certificate authentication for a custom connector:
Steps to Create a Custom Connector with Client Certificate Authentication
Prepare the Client Certificate:
Ensure you have a valid client certificate. This certificate should be in a format supported by PowerApps, such as .pfx or .pem.
Create the Custom Connector:
Navigate to PowerApps and sign in.
Go to Dataverse and select Custom Connectors.
Click on New Custom Connector and choose Create from blank.
Define General Information:
Provide a name for your custom connector.
Optionally, upload an icon and set the background color.
Set Up the Host and Base URL:
In the General tab, specify the host and base URL for your API.
Configure Security:
In the Security tab, you typically see options like API Key, OAuth 2.0, and Basic Authentication. If client certificate authentication is not visible, you might need to configure it manually.
Select No Authentication for now, as you will handle authentication in the next steps.
Define the API:
In the Definition tab, define the actions and triggers for your API. Specify the request and response formats.
Handle Client Certificate Authentication:
Since the direct option for client certificate authentication might not be available, you can handle it programmatically within your connector.
Use the Code tab to write custom code that includes the client certificate in the request headers.
Example Code for Including Client Certificate
Here is an example of how you might include the client certificate in the request headers using custom code:
const https = require('https');
const fs = require('fs');
// Load the client certificate
const clientCert = fs.readFileSync('path/to/client-cert.pem');
const clientKey = fs.readFileSync('path/to/client-key.pem');
// Create an HTTPS agent with the client certificate
const agent = new https.Agent({
cert: clientCert,
key: clientKey,
});
// Define the request options
const options = {
hostname: 'api.example.com',
port: 443,
path: '/endpoint',
method: 'GET',
agent: agent,
};
// Make the request
const req = https.request(options, (res) => {
let data = '';
res.on('data', (chunk) => {
data += chunk;
});
res.on('end', () => {
console.log(data);
});
});
req.on('error', (e) => {
console.error(e);
});
req.end();
Final Steps
Test the Connector:
Test the custom connector to ensure that the client certificate authentication works as expected.
Publish the Connector:
Once tested, publish the custom connector for use in your PowerApps environment.
Additional Resources
Microsoft Documentation: Refer to the Microsoft Learn module on configuring custom connectors with authenticated APIs.
Community Forums: Check the PowerApps Community for discussions and solutions related to client certificate authentication.
If you need further assistance or have specific questions, feel free to ask!