Repository navigation
OAuth2 + Connection Parameters during connection creation. #3771
Replies: 3 comments 5 replies
|
Hi Louis-Philippe, |
|
Is this for a certified connector or for an internal connector? Let me alert the connector team to see if something has changed on the backend. |
|
Yes, policy expressions can read connection parameters. Microsoft's Set HTTP Header policy documents For your schema, if "x-ms-apimTemplateParameter.value": "@connectionParameters('project_url', '')"Make sure every set that needs the header defines that parameter. Your observation that the field appears when creating the connection from the Connections page is a useful clue; I'd test the connection through that path and verify the resulting header in a run. This confirms the request-policy use case; I would test dynamic OAuth scopes separately, since the cited expression documentation covers policy values, not scope configuration. See also Microsoft's multi-auth documentation. |
Uh oh!
There was an error while loading. Please reload this page.
I am trying to create a custom connector that will authenticate the users using OAuth2, but also need to ask for a project URL. That pattern works fine when using API Key, but doesn't seem to be working when configured for OAuth. I have 2 specific need, the first one is to be able to as for the project URL, which would then be set as a header for requests made by the power platform using the set header policy.
The other one I would like to do, is to transform the OAuth2 requests to use the same project URL in the scopes of the OAuth2 request. Basically having dynamic scopes.
I tried this for the first requirement of the header, but no luck in getting the UI to ask for the Project URL:
{ "properties": { "connectionParameters": { "token": { "type": "oauthSetting", "oAuthSettings": { "identityProvider": "oauth2", "clientId": "c995f09f-8f94-4c92-99f7-c3c4d61bc22e", "scopes": [ "openid" ], "redirectMode": "GlobalPerConnector", "redirectUrl": "https://global.consent.azure-apim.net/redirect/experlogix-20cpq3-5f7895d93834834834-5fef17f9c88018564c", "properties": { "IsFirstParty": "False", "IsOnbehalfofLoginSupported": false }, "customParameters": { "AuthorizationUrl": { "value": "https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize" }, "TokenUrl": { "value": "https://login.microsoftonline.com/organizations/oauth2/v2.0/token" }, "RefreshUrl": { "value": "https://login.microsoftonline.com/organizations/oauth2/v2.0/token" } } }, "uiDefinition": { "displayName": "OAuth Connection", "description": "OAuth Connection", "constraints": { "required": "true", "hidden": "false" } } }, "project_url": { "type": "string", "uiDefinition": { "constraints": { "required": "true", "hidden": "false" }, "description": "The URL to your CPQ project.", "displayName": "Project URL", "tooltip": "Provide the URL to your CPQ project." } } }, "iconBrandColor": "#007ee5", "capabilities": [], "publisher": "Louis-Philippe Perras", "policyTemplateInstances": [ { "templateId": "setheader", "title": "ProjectUrlHeaderPolicy", "parameters": { "x-ms-apimTemplateParameter.name": "X-PROJECT-URL", "x-ms-apimTemplateParameter.value": "@connectionParameters('project_url','')", "x-ms-apimTemplateParameter.existsAction": "override", "x-ms-apimTemplate-policySection": "Request" } } ] } }I tried changing the order of the connection parameters but it looks like as soon as it finds a token of type oauthSetting, it won't look at the others. Is there anything I'm not seeing on how to accomplish this?
Thanks!
All reactions