Custom Graph API Connector

This tutorial demonstrates the process of creating a custom connector to effectively utilize the Graph API.

What is the Graph API?

The Graph API is a tool provided by Microsoft that helps developers access a wide range of information and features from Microsoft services like Microsoft 365 and Azure. It acts as a central hub where developers can retrieve data and perform actions related to things like user accounts, files, emails, and calendars. It’s designed to make it easier for developers to build applications that work well with Microsoft’s services, allowing them to create seamless and efficient experiences for users.

We can levarage that API to use it to our advance in PowerAutomate and in PowerApps

Step 1: Azure App Regisitration

The first step we have to do is to create a Apllication in Azure AD.

  1. Visit the Azure portal at portal.azure.com and sign in using your Azure account credentials.
  2. In the Azure AD management interface, select „App registrations“ .
  3. Click on „New registration„: Click on the „New registration“ button to create a new app registration.
  4. In the „Register an application“ page, enter a name for your app registration in the „Name“ field.
    Optionally, you can choose the supported account types for your application (single tenant, multi-tenant).
    Required is the following Redirect URI
https://global.consent.azure-apim.net/redirect
  1. Click on „Register„.
  2. Configure required permissions: To grant your app registration the necessary permissions to access the Graph API
    • Make sure the Type of Permission is set to DELEGATED and not APPLICATION
  3. After that, give grant admin consent to activate the API
  4. Now Navigate to Certificates & Secrets
  5. Now create a Secret Key and Save the Value

Step 2: Create a Connector

  1. Go to the PowerAutomate
  2. Click In the Navigaten Pane on the Left Data > Custom Connector
  3. Click + New Custom Connector and select From Blank
  4. After that you can upload a Icon and provide a Description
    • For Scheme: https
    • For Host: graph.microsoft.com
    • And Base URL: /

Insert Application Details / Security Tab

  1. In the Authentification Type choose OAuth2.0
  2. Select Azure Active Directoy as Indentity Provider
  3. Insert the Client ID and the Secret from your App you registered in the step before
  4. As Resource URL put https://graph.microsoft.com
  5. Save the Connector

After saving it, it should display the Redirect URL as you see in the Screenshot at the bottom.
I gave you the address in the previous step but if it is different to what it displays here. Copy he Value and add it as Redirect WEB URL in the Azure Application

Congratulations on successfully creating a connector to the Graph API! Now, the final step remaining is to add an action to utilize the connector.

To keep this tutorial simple, let’s add an action that returns a specific user by providing their User Principal Name (UPN).

Step 3: Add an Action

To add an Action to our Connector we go to the Definiton Tab and Select New action on the left side.

  1. Give the Action a name: „Get User“
  2. Provide a Description for the Action and give them a Unique ID. Usally the first letter is small and for any new Word user Uppercase : „getUser“ or „getUserDetails“
  3. If you want your action to appear as a normal action in the Power Automate pane, set its visibility to „None“. Any other visibility settings will require users to click on „See more“ in the action pane of Power Automate to access your action.
  4. Select the Import from Sample under the Request
  5. In the Panel select GET as the Verb (the Request you will send to the Graph API)
  6. Provide the URL As following: „/v1.0/users/{upn}“
    • beta is the Version of the Graph API you use. For most usecases v1.0 is enough but some infos like shifts (Microsoft Teams) can only be obtained with the /beta/ version of the Graph API
    • {upn} is the Variable Name the User in PowerAutomate will see for providing when he uses the Action. For any Variables in the URL use curly brackets to make them as providing variables
  7. In this example you can leave the Header as it is.
  8. Select Import

As you see in the Second Screenshot, the Variable upn is now under path were you could edit it and even set the a default value.

After you are ready save the Connector and Test it out.

If you want a further tutorial for Graph API actions, please leave a comment.

CATEGORIES:

PowerAutomate

No responses yet

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert

Latest Comments