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
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

V3_PVA CAmpaign Carousel.png

Community Challenge - Giveaways!

Participate in the Power Virtual Agents Community Challenge

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Carousel April Dunnam Updated 768x460.jpg

Urdu Hindi D365 Bootcamp

Dont miss our very own April Dunnam’s The Developer Guide to the Galaxy! Find out what the Power Platform has to offer for the traditional developer.

Top Solution Authors
Top Kudoed Authors
Users online (2,992)