cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
coder-bec
New Member

Custom Connector with specific oauth2 requirements

I am building a custom connector that has very specific oauth2 requirements. I am very close but still missing a couple of things. It's for this API:

 

https://api.vincere.io/

 

The body of the token request and token refresh calls need to be submitted as form data with this header: 

Content-type: application/x-www-form-urlencoded

 

The successful token request returns an ID_token that needs to be used in the header of subsequent authenticated API calls, along with an x-api-key header. 

 

I think I am very close to most of this except the form header and the id token: 

 

{
  "properties": {
    "connectionParameters": {
      "host": {
        "type": "string",
        "uiDefinition": {
          "constraints": {
            "required": "true"
          },
          "description": "Specify tennant id for your vincere installation",
          "displayName": "Vincere tennant",
          "tooltip": "e.g. contoso.vincere.io"
        }
      },
      "api_key": {
        "type": "securestring",
        "uiDefinition": {
          "displayName": "API Key",
          "description": "The API key for your company",
          "tooltip": "Provide your API Key",
          "constraints": {
            "required": "true"
          }
        }
      },
      "token": {
        "type": "oauthSetting",
        "oAuthSettings": {
          "identityProvider": "oauth2",
          "clientId": "<clientID>",
          "scopes": [],
          "redirectMode": "Global",
          "redirectUrl": "https://global.consent.azure-apim.net/redirect",
          "properties": {
            "IsFirstParty": "False"
          },
          "customParameters": {
            "authorizationUrl": {
              "value": "https://id.vincere.io/oauth2/authorize"
            },
            "authorizationUrlQueryString": {
              "value": "?response_type=code&client_id={clientId}&redirect_uri={redirectUrl}&state=STATE"
            },
            "authorizationBodyTemplate": {
              "value": "?code={authorizationCode}&state=STATE"
            },
            "tokenUrl": {
              "value": "https://id.vincere.io/oauth2/token"
            },
            "tokenUrlQueryString": {
              "value": "?client_id={clientId}&code={authorizationCode}&grant_type=authorization_code"
            },
            "tokenBodyTemplate": {
              "value": "?access_token={clientId}&refresh_token={authorizationCode}&id_token={authorizationCode}&token_type={tokenType}&expires_in={expiresIn}"
            },
            "refreshUrl": {
              "value": "https://id.vincere.io/oauth2/token"
            }
          }
        }
      }
    },
    "iconBrandColor": "#007ee5",
    "capabilities": [],
    "policyTemplateInstances": [
      {
        "templateId": "setheader",
        "title": "Set API-Key header",
        "parameters": {
          "x-ms-apimTemplateParameter.name": "x-api-key",
          "x-ms-apimTemplateParameter.value": "@connectionParameters('api_key','')",
          "x-ms-apimTemplateParameter.existsAction": "override",
          "x-ms-apimTemplate-policySection": "Request",
          "x-ms-apimTemplate-operationName": [
            "GetCurrentUser"
          ]
        }
      },
      {
        "templateId": "setheader",
        "title": "Set id Token header",
        "parameters": {
          "x-ms-apimTemplateParameter.name": "id-token",
          "x-ms-apimTemplateParameter.value": "<what to put here?>",
          "x-ms-apimTemplateParameter.existsAction": "override",
          "x-ms-apimTemplate-policySection": "Request",
          "x-ms-apimTemplate-operationName": [
            "GetCurrentUser"
          ]
        }
      },
      {
        "parameters": {
          "x-ms-apimTemplateParameter.urlTemplate": "https://@connectionParameters('host')"
        },
        "templateId": "dynamichosturl",
        "title": "Route to API host"
      }
    ],
    "publisher": "Bec Martin"
  }
}

 

1 REPLY 1
v-bofeng-msft
Community Support
Community Support

Hi @coder-bec :

Using Graph API to customize the connector also needs to use the oauth2 type, so I think this video may help you:

How to connect Microsoft Graph API in PowerApps 

Best Regards,

Bof

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Top Solution Authors
Top Kudoed Authors
Users online (1,250)