We are writing a WCF service which has to integrate with Dynamics CRM 2016 Online. I\'m trying to authenticate using ADAL, using method AcquireTokenAsync(). Pro
Okay, ended up finding a solution for this.
Provided you have registered your application with Azure AD (as a Web App / Web API, not a Native Application), you will receive a client ID and a secret key for that application.
The code to acquire the token without having a pop-up window is as follows:
AuthenticationParameters ap = AuthenticationParameters.CreateFromResourceUrlAsync(
new Uri(resource+"/api/data/v8.1")).Result;
AuthenticationContext ac = new AuthenticationContext(ap.Authority);
AuthenticationResult r = await ac.AcquireTokenAsync(ap.Resource, new ClientCredential(clientId,clientSecret));
resource is the base URL of your Dynamics CRM deployment.
Authentication parameters are discovered at run time as suggested in this MSDN acticle.