0

We want to get the power-automate data like all environments, flows (single and multiple), Apps (single and multiple) using REST API. Same way you can get the SharePoint site information using Graph API and an App Registration.

We have created and registered the app registration and added the required permissions to the application. We can get the data using PowerShell, but at the moment it is not sustainable. Is there a way to get the data using the app registration or a service principal?

1

1 Answer 1

0

To get the Power-Automate data like all environment variables using REST API

Initially, I registered Microsoft Entra ID Single Tenant application:

enter image description here

Added Power Automate API permission and Granted Admin Consent:

enter image description here

As I generated access token using client credentials with below parameteres:

POST https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded

client_id: <application-id>
client_secret: <client-secret>
scope:https://service.flow.microsoft.com/.default
grant_type: authorization_code

Response:

enter image description here

GET https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01"

Response:

enter image description here

By using client credentials, you were to fetch enviorments but you were not able to get the flows as it is not supported.

To get the flows need to generate access token using delegated type flow like authorization_code flow.

Using delegated type, authorization_code flow which requires user-interaction.

To get code, I ran below authorization request in browser:

https://login.microsoftonline.com/<tenant_id>/oauth2/v2.0/authorize?  
client_id=<client_id>
&response_type=code  
&redirect_uri=https://jwt.ms
&response_mode=query  
scope:https://service.flow.microsoft.com/.default
&state=12345

enter image description here

After successfully creating authorization_code, Generated access token using below parameters:

GET https://login.microsoftonline.com/<tenant-id>/oauth2/v2.0/token
Content-Type: application/x-www-form-urlencoded

client_id: <application-id>
client_secret: <client-secret>
scope:https://service.flow.microsoft.com/.default
grant_type: authorization_code
code: <authorization_code generated from browser>
redirect_uri: <REDIRECT_URI 

enter image description here

Now use same access token to get the flow:

GET https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple/environments/<enviornement-name>/flows?api-version=2016-11-01"

enter image description here

Reference:

SO Thread by me

Power-Automate

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.