Hello,
I have an MCP server which supports 3 kinds of authentication mechanism,
1. API key auth
2. Oauth
3. Microsoft's Service Principal auth.
{
"properties": {
"connectionParameterSets": {
"uiDefinition": {
"displayName": "Authentication Type",
"description": "Type of authentication to be used."
},
"values": [
{
"name": "api-key-auth",
"uiDefinition": {
"displayName": "API Key",
"description": "Connect using an API key."
},
"parameters": {
"api_key": {
"type": "securestring",
"uiDefinition": {
"displayName": "API Key",
"description": "The API Key for this api",
"tooltip": "Provide your API Key",
"schema": {
"description": "The API Key for this api",
"type": "securestring"
},
"constraints": {
"tabIndex": 2,
"clearText": false,
"required": "true"
}
}
}
}
},
{
"name": "oauth2-auth",
"uiDefinition": {
"displayName": "OAuth Connection (Enlyft Login)",
"description": "Sign in using your Enlyft login"
},
"parameters": {
"token": {
"type": "oauthSetting",
"oAuthSettings": {
"identityProvider": "oauth2",
"clientId": "m2m_******",
"clientSecret": "6G******",
"scopes": [
"openid email profile offline_access"
],
"redirectMode": "GlobalPerConnector",
"redirectUrl": "https://global.consent.azure-apim.net/redirect/******",
"properties": {
"IsFirstParty": "False"
},
"customParameters": {
"authorizationUrl": {
"value": "https://our.auth.server/oauth/authorize"
},
"tokenUrl": {
"value": "https://our.auth.server/oauth/token"
},
"refreshUrl": {
"value": "https://our.auth.server/oauth/token"
}
}
},
"uiDefinition": {
"displayName": "OAuth Connection",
"description": "Sign in using your Enlyft login",
"constraints": {
"required": "true",
"hidden": "false"
}
}
}
},
"metadata": {
"allowSharing": false
}
},
{
"name": "oAuthClientCredentials",
"uiDefinition": {
"displayName": "Service Principal Connection",
"description": "Service Principal Connection"
},
"parameters": {
"token": {
"type": "oauthSetting",
"oAuthSettings": {
"identityProvider": "aad",
"clientId": "94********",
"scopes": [
"openid email profile"
],
"redirectMode": "GlobalPerConnector",
"redirectUrl": "https://global.consent.azure-apim.net/redirect/cr76b-5fenlyft-20mcp-5fdfe306432e985ff0",
"properties": {
"IsFirstParty": "False",
"AzureActiveDirectoryResourceId": "api://94******",
"IsOnbehalfofLoginSupported": true
},
"customParameters": {
"grantType": {
"value": "client_credentials"
},
"LoginUri": {
"value": "https://login.microsoftonline.com"
},
"TenantId": {
"value": "d4*******"
},
"ResourceUri": {
"value": "api://94*********"
},
"EnableOnbehalfOfLogin": {
"value": "false"
}
}
},
"uiDefinition": {
"displayName": "Service Principal Connection",
"description": "Service Principal Connection",
"constraints": {
"required": "false",
"hidden": "true"
}
}
},
"token:clientId": {
"type": "string",
"uiDefinition": {
"displayName": "Client ID",
"schema": {
"type": "string",
"description": "Client (or Application) ID of your application"
},
"constraints": {
"required": "true",
"hidden": "false"
}
}
},
"token:clientSecret": {
"type": "securestring",
"uiDefinition": {
"displayName": "Client Secret",
"schema": {
"type": "securestring",
"description": "Client secret of your application"
},
"constraints": {
"required": "true",
"hidden": "false"
}
}
},
"token:TenantId": {
"type": "string",
"uiDefinition": {
"displayName": "Tenant",
"schema": {
"type": "string",
"description": "The tenant ID of your application"
},
"constraints": {
"required": "true",
"hidden": "false"
}
}
}
},
"metadata": {
"allowSharing": true
}
}
]
},
"iconBrandColor": "#FCFCFC",
"capabilities": [
"actions"
],
"policyTemplateInstances": [],
"publisher": "Vivek Kothari"
}
}
With this I am able to see a screen like below.
This works in my powerapps environment where I am developing the solution as it has the client secret, but when I export this as a managed solution and import it in different environment, and try the oauth, I get following error,
OAuth2 Authorization Flow failed for service Generic Oauth 2. No key 'clientsecret' for code={Code}&grant_type=authorization_code&redirect_uri={RedirectUrl}&client_id={ClientId}&client_secret={ClientSecret}
I checked the managed solution zip and the client secret is removed (understandable), but my question is then how am I able to distribute my solution while ensuring that the client secret of my Oauth app is securely distributed to all my users?