I have an web app that has been defined on Azure AD to have permission to a Dynamics 365 (Delegated Permissions).
And I'm using Client Credentials Grant to get Access Token from azure AD. So I'm doing this:
var clientCredential = new ClientCredential(clientId, clientSecret);
var result = authContext.AcquireTokenAsync(dynamicsTenant, clientCredential).Result;
But I keep getting HTTP 401 when I try to access the Web APIs like this:
var response = httpClient.GetAsync(dynamicsTenant + "/api/data/v8.1/contacts").Result;
It works with Resource Owner Password Credentials Grant, like this:
var userCredential = new UserPasswordCredential("crmuser", "crmpwd");
var result = authContext.AcquireTokenAsync(dynamicsTenant, clientId, userCredential).Result;
Is there a possible configuration on Dynamics 365 that could be prohibiting the access?
My aim is to consume the Dynamics (Online) Web API from a (headless) confidential client.