Skip to main content



No record found.

Microsoft Dynamics CRM forum

Can i use ADAL authintication in Dynamics 365 on-premise (2015/2016/8.2/9.0/9.1/9.2)

Posted on by 40

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("">", endPoint));

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



Surajit Kundu

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,914 Super User

Martin Dráb Profile Picture

Martin Dráb 225,549 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans