Jump to content

Featured Replies

Posted

mediumvv2px400.jpg.c1aefdbdd80edc810809f6545f644640.jpg

 

 

 

Credits- Welcome

 

Now that we are well acquainted with power apps and creating a microsoft graph custom connector in it, let us familiarize ourselves with the following terms once so that we can proceed to call Microsoft graph API in Power Automate using custome connectors for which we will require to set the criteria in authentication.

 

 

 

Azure API Management Gateway

 

 

Custom connectors are supported by Microsoft Azure API Management infrastructure. When a connection to the underlying API is created, the API Management gateway stores the API credentials or tokens, depending on the type of authentication used, on a per-connection basis in a token store. This solution enables authentication at the connection level.

 

mediumvv2px400.png.453570c67888d3e3e3980d31198ec346.png

 

 

 

Credits- File:Crypto key.svg - Wikimedia Commons

 

 

 

Azure API Authentication

 

 

Before using any connector in Azure Logic Apps, Power Automate, or Power Apps, the user needs to create a connection by authenticating to the network service. There are different types of authentication.

 

  1. No authentication- No further information is required.
  2. Basic authentication- The user will provide the user name and password to create the connection.
  3. API Key- Used by web services. Make sure that you define- Parameter label, Parameter name, Parameter location
  4. OAuth 2.0 authentication- Available for online connectors. Provides implementations for specific services and prebuilt identity provider templates, when selected, fill in many of the fields that are required by OAuth 2.0.
  5. Windows authentication- Available only for connections that use on-premises data gateway, when the Connect via on-premises data gateway check box is set on the General tab. When a new connection is created, the user will need to provide Windows credentials for the service and then select one of the installed on-premises gateways.

 

 

 

Azure AD Authentication

 

 

mediumvv2px400.png.c60c360bb8af22756d1962977bcbd0df.png

 

 

 

 

 

Prerequisites

 

 

An account on Power Apps Portal, Graph Explorer, Microsoft Azure.

 

 

 

Let's get started!

 

 

Step 1: Create a new solution.

 

  1. Go to Power Apps maker portal and make sure to be in the correct environment.
  2. Select Solutions > + New solution and enter the following details.
  3. Don't navigate away from this page after selecting 'Create'.

 

mediumvv2px400.png.13dd063bdcab1a1e70d39473ff1c8e67.png

 

 

 

Step 2: Use Graph Explorer to test the API.

 

  1. Sign in to the Graph Explorer and use it to test the API. Read the permissions and continue if you agree.
  2. Make sure that GET is selected for the verb, add /insights/used to the URL, and then select Run query.
  3. You should get a 403 error indicating that Graph Explorer lacks your permission to perform this action.
  4. Select the Modify permissions tab to grant Graph Explorer permission > Select Sites.Read.All > Consent.
  5. Read the requested permissions, continue if you agree and select Run query again.

 

mediumvv2px400.png.e7400de5a21a961401568a840f9cab85.png

 

 

 

  1. Start a new browser session tab. Sign in to OneDrive Personal Cloud Storage.
  2. Select + New and select Word document.

 

mediumvv2px400.png.3496506e9c3330c65018b2ddf4ea62b9.png

 

 

 

  1. Enter some test text in the Word file. The document will be saved automatically for you.
  2. Go back to the Graph Explorer and run the same query again.
  3. You should now get a response with values. Select the response JSON, right-click, select Copy, and then save it.

 

mediumvv2px400.png.e9233184ce01442c5483379449c9702a.png

 

 

 

Step 3: Register a new application and add permissions.

 

  1. Sign in to Microsoft Azure with your user admin credentials.
  2. Select Show portal menu and then select Azure Active Directory.

 

mediumvv2px400.png.123fb7b1748432caefe73e4b78c6e515.png

 

 

 

  1. Enter Learn last used connector for Name, enter https://global.consent.azure-apim.net/redirect for Redirect URI, and then select Register.

 

mediumvv2px400.png.1c85cb47baa2e0a479b4a5d4f8c2a7d9.png

 

 

 

  1. Select API permissions and then select + Add a permission.

 

mediumvv2px400.png.b43c3c9122d6af4e231199a81a7c9528.png

 

 

 

  1. Select Certificates & secrets and + New client secret.
  2. Enter Last used connector action for Description, select In 1 year for Expires, and then select Add.
  3. Copy the Value and save it for later because it won't be shown again. You will use this user secret when creating the connector.
  4. Select Overview, copy the Application (Client) ID and save it on a notepad. You'll use this client ID when creating the connector.

 

mediumvv2px400.png.17f3cdbd6da08145efc679d73bbb5f58.png

 

 

 

Step 4: Create a custom connector.

 

  1. Make sure to sign in and be in the right environment in the Power Apps Admin Portal.
  2. Select Solutions and then select to open the Contoso graph solution that you created in 'Step 1: Create a new solution'.
  3. Select + New > Other > Custom connector.
  4. Enter Contoso graph for Connector name, scroll down, enter graph.microsoft.com for Host and /v1.0 for Base URL and select Security.

 

mediumvv2px400.png.baba82e881b204abdc851b2ed5a6b56c.png

 

 

 

  1. Select OAuth 2.0 for Authentication and Azure Active Directory for Identity Provider.
  2. Paste the ID that you copied from Azure in the Client id field and then paste the Value that you copied from Azure in the Client secret field.
  3. Enter https://graph.microsoft.com for Resource URL and then select Create connector. Don't navigate away from the page.

 

mediumvv2px400.png.9bf24f4305c1b1f18333fdd4b16ab8a2.png

 

 

 

Step 5: Add the action.

 

  1. Select Definition > + New action.
  2. Enter Last used for Summary and LastUsed for Operation ID. Go to the Request section and select + Import from sample.
  3. Select Get for the verb, enter /me/insights/used for URL, and then select Import. Scroll down and select the default response.
  4. Select + Import from sample. Paste the response that you copied from Graph Explorer in the Body field and then select Import.

 

mediumvv2px400.png.7f45d7b0b1e42ac2ef6d99625b13c14e.png

 

 

 

  1. Select Update connector. Don't navigate away from this page.

 

Step 6: Test the connector.

 

  1. Select the Test tab and then select + New connection.
  2. Provide your credentials. Read the requested permissions and continue.
  3. Select Refresh connections and Test operation. You should see a 200 status, and the response should look like the image.

 

mediumvv2px400.png.2dd5459f8e7c8287b1b49220bdacb2dd.png

 

 

 

 

 

Summary

 

 

Congratulations! You have now created an environment to call Microsoft Graph API in Power Automate and can proceed to learn more in this area. Do leave your feedback in the comments below. Our next blog will on how to connect Power BI to Microsoft Graph. Stay tuned!

 

 

 

Next Steps

 

 

More info on overview of Microsoft Graph

 

Basics of Power BI

 

Continue reading...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...