DEV Community

Cover image for Streamline Power platform Integration with Graph API & Custom Connectors
Seena Khan
Seena Khan

Posted on

Streamline Power platform Integration with Graph API & Custom Connectors

Introduction

Microsoft Graph API serves as a powerful gateway to access Microsoft 365 services, allowing developers to integrate data and automate workflows efficiently. When building a custom connector, leveraging Graph API enhances the capabilities of Power Platform applications, enabling seamless authentication and interaction with Microsoft services like Outlook, SharePoint, Teams, and OneDrive.

In this guide, we will explore the step-by-step process of integrating Microsoft Graph API into a custom connector in Power Automate or Power Apps.

Step 1: Register an Application in Azure AD

Before accessing Graph API, you must register an application in Azure Active Directory (Azure AD) to obtain authentication credentials.

  1. Navigate to Azure Portal.
  2. Go to Azure Active DirectoryApp registrations.
  3. Click New registration and enter:
    • Name: Your custom connector app name
    • Supported account types: Choose appropriate option
    • Redirect URI: Required for authentication (e.g., https://login.microsoftonline.com/common/oauth2/nativeclient)
  4. Click Register, and note the Application (client) ID and Tenant ID.

Step 2: Configure API Permissions

To allow your connector to access Graph API, you need to assign API permissions:

  1. Go to your registered appAPI permissions.
  2. Click Add a permissionMicrosoft Graph.
  3. Choose Delegated or Application permissions, depending on your use case.
  4. Grant necessary permissions such as:
    • User.Read (Read user profiles)
    • Mail.Read (Access emails)
    • Files.ReadWrite (Manage files on OneDrive)
  5. Click Grant admin consent to approve permissions.

Step 3: Generate Authentication Credentials

To authenticate requests, generate a client secret or use certificates:

  1. Go to Certificates & secretsNew client secret.
  2. Enter a description and expiration period.
  3. Click Add and copy the Client Secret Value (it will not be visible again).

Step 4: Create the Custom Connector in Power Automate

Now, set up the custom connector using Graph API in Power Automate:

  1. Open Power AutomateCustom Connectors.
  2. Click Create a custom connectorBlank connector.
  3. Enter a name, then move to the Security section:
    • Choose OAuth 2.0 authentication.
    • Set https://login.microsoftonline.com/{tenant_id}/oauth2/token as the token URL.
    • Provide Client ID and Client Secret from Azure.
    • Define the scope (e.g., https://graph.microsoft.com/.default).

Step 5: Define API Endpoints

To interact with Graph API, configure requests within the custom connector:

  1. In Definition, click New action.
  2. Set the summary and operation ID (e.g., GetUserDetails).
  3. Configure the request:

    • URL: https://graph.microsoft.com/v1.0/me
    • Method: GET
    • Headers:
     {
       "Authorization": "Bearer {access_token}"
     }
    
  4. Test the request and validate the API response.

Step 6: Test and Deploy the Connector

  1. Save and publish the custom connector.
  2. Create a Power Automate flow or Power Apps integration using the connector.
  3. Monitor API calls using Graph Explorer or Azure Application Insights.

Conclusion

By integrating Graph API into a custom connector, you unlock advanced capabilities in Power Platform solutions. Whether accessing user profiles, emails, files, or Teams data, Microsoft Graph enables powerful automation and data retrieval.

Real-World Scenario: Automating Employee Onboarding with Microsoft Graph API

Use Case

A company uses Microsoft 365 for communication and collaboration. To streamline the onboarding process, they want to automate the creation of new employees’ Microsoft Teams accounts, assign them to Teams channels, and provision OneDrive folders using Graph API and a custom connector in Power Automate.

Solution Overview

Using Microsoft Graph API, the custom connector in Power Automate will:

  • Retrieve employee details from an HR database.
  • Create a new Teams user and assign them to relevant channels.
  • Provision a OneDrive folder for storing their onboarding documents.
  • Send a welcome email with login credentials and company resources.

Step-by-Step Implementation

Step 1: Set Up the Custom Connector

Follow the steps in the previous guide to configure authentication using Azure AD and Graph API permissions, ensuring the connector has access to:

  • User.ReadWrite.All (for managing users)
  • Group.ReadWrite.All (for assigning Teams membership)
  • Files.ReadWrite.All (for provisioning OneDrive folders)

Step 2: Retrieve Employee Details

A Power Automate flow triggers when a new employee record is added to the HR database.

  • HTTP Request to Graph API:
   GET https://graph.microsoft.com/v1.0/users/{newUserEmail}
   Authorization: Bearer {access_token}
Enter fullscreen mode Exit fullscreen mode
  • If the user does not exist, proceed to account creation.

Step 3: Create a Microsoft Teams User

  • API Request to Add User:
   POST https://graph.microsoft.com/v1.0/users
   Content-Type: application/json
   Authorization: Bearer {access_token}
Enter fullscreen mode Exit fullscreen mode
  • Payload:
   {
     "displayName": "John Doe",
     "mail": "john.doe@company.com",
     "passwordProfile": {
       "forceChangePasswordNextSignIn": true
     }
   }
Enter fullscreen mode Exit fullscreen mode
  • This automatically creates a new Microsoft 365 user with a temporary password.

Step 4: Assign the User to Teams Channels

  • Add the new employee to the "Onboarding" channel:
   POST https://graph.microsoft.com/v1.0/groups/{teamId}/members
Enter fullscreen mode Exit fullscreen mode
  • The employee can now access training materials and orientation sessions directly from Teams.

Step 5: Provision OneDrive Folder

  • Create a dedicated OneDrive folder for the new user:
   POST https://graph.microsoft.com/v1.0/users/{newUserId}/drive/root/children
Enter fullscreen mode Exit fullscreen mode
  • This ensures employees have direct access to onboarding documents.

Step 6: Send a Welcome Email

Using Microsoft Graph API, send an email with credentials and onboarding resources:

   POST https://graph.microsoft.com/v1.0/users/{newUserId}/mailfolders/inbox/messages
Enter fullscreen mode Exit fullscreen mode
  • Include helpful links and company policies in the email body.

Business Impact

Reduced manual work—HR staff no longer need to create accounts manually.

Consistent onboarding experience—every employee receives standardized training resources.

Improved security—credentials are managed automatically with Azure AD authentication.

Hope you enjoy the session.

Please leave a comment below if you have any further questions.

Happy Sharing !!!
Keep Learning | Spread Knowledge | Stay blessed |

Top comments (0)