We managed to solve this by checking out other open sourced certified connectors.
Using paconn we download the apiProperties.json
The identityProvider was set to oauth2, when it should have been oauth2generic (which is what we have selected in the UI).
Then under the custom parameters we now have access to templating options for the authorization calls:
"customParameters": {
"authorizationUrlTemplate": {
"value": "https://mydomain.com/authorize"
},
"authorizationUrlQueryStringTemplate": {
"value": "?audience=https://mydomain.com&scope={scopes}&redirect_uri={redirectUrl}&client_id={ClientId}&response_type=code&state={State}"
},
"tokenUrlTemplate": {
"value": "https:///mydomain.com/oauth/token"
},
"tokenBodyTemplate": {
"value": "audience=https://mydomain.com&scope={scopes}&redirect_uri={redirectUrl}&client_id={ClientId}&client_secret={ClientSecret}&code={Code}&grant_type=authorization_code"
},
"refreshUrlTemplate": {
"value": "https://mydomain.com/oauth/token"
},
"refreshBodyTemplate": {
"value": "audience=https://mydomain.com&scope={scopes}&redirect_uri={redirectUrl}&client_id={ClientId}&client_secret={ClientSecret}&refresh_token={RefreshToken}&grant_type=refresh_token"
},
"scopeListDelimiter": {
"value": " "
}We were unable to find any documentation at all about these properties or how they work or what things the apiProperties.json file supports. We basically had to reverse engineer other connectors with trial error wasting a lot of time for this...
All we found was another user asking for documentation for these things which was never properly replied to: https://powerusers.microsoft.com/t5/Connector-Development/OAuth2-customParameters/td-p/1582874