Hi,
We are trying to use the Power Automate Web API by connecting to "https://*****.crm.dynamics.com/" ( where ***** is the environment URL retrieved from the power platform admin center) using the token generated using MSAL. The access or the bearer token is created just fine by using the client ID of our custom registered app but when this same token is passed to connect to https://*****.crm.dynamics.com/" ( i.e set scope as https://*****.crm.dynamics.com/.default) , to retrieve the flow definitions (client_data), we are running into 403 Forbidden error. Please see the code snippet below -- The error 403 is thrown on line where GetAsync method is called.
private string GetMasterFlowClientData(string resource, string accessToken, string FlowName)
{
try
{
using (var client = new HttpClient())
{
client.BaseAddress = new Uri(resource "/api/data/v9.1/");
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", accessToken);
client.Timeout = new TimeSpan(0, 2, 0);
client.DefaultRequestHeaders.Add("OData-MaxVersion", "4.0");
client.DefaultRequestHeaders.Add("OData-Version", "4.0");
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var response = client.GetAsync(string.Format("workflows?$filter=name eq '{0}'", FlowName)).Result;
if (response.IsSuccessStatusCode)
{
//..
}
How do we connect to https://*****.crm.dynamics.com/ using the access token generated using MSAL?
Is it possible to give permissions to an app in Azure from Dynamics 365? or should we have to add https://*****.crm.dynamics.com/ into the app registrations in Azure?
How can we make our app communicate successfully with https://*****.crm.dynamics.com/ where our flows are stored?
Any help is greatly appreciated. Thank you in advance.
Regards
SLS