Hi Expert ,

    I am currently using Dynamics 365 CRM Online version and use  Azure Active Directory Authentication Library (ADAL)  for API / Webservice authentication .For this authentication i have to registered my app with Microsoft Azure Active Directory. I am little bit confusion can i use same authentication step for the on-premise versions (2015 / 2016 / 8.2 / 9.0 /9.1/ 9.2) . Below is my code for Crm online which is working fine can i use same code my onpremise versions.

AuthenticationParameters ap = AuthenticationParameters.CreateFromResourceUrlAsync(new Uri(credential.companyUrl)).Result;
var creds = new ClientCredential(credential.clientId, credential.clientSecret);
AuthenticationContext authContext = new AuthenticationContext(ap.Authority);
string token = authContext.AcquireTokenAsync(ap.Resource, creds).Result.AccessToken;

string endPoint = "products?$select= * &$filter=productnumber eq ghj78888";
var httpClient = HttpWebRequest.CreateHttp(Path.Combine("">insyncdemo.api.crm8.dynamics.com/.../", endPoint));

httpClient.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + token);
using (var sr = new StreamReader(httpClient.GetResponse().GetResponseStream()))
responseData = sr.ReadToEnd();



Surajit Kundu