0
votes

I am currently in the process of trying to get the data from Dynamics CRM (Office 365 - E5) using the Web API query method like api.crm.dynamics.com/api/data/v8.2/accounts?$select=accountid,name,new_gl_exp,new_autol_exp

I will include this api within the external application (Developed using HTML & Javascript) & hosted in on-premises IIS

I have done the basic setting in both CRM & Azure and got the token after logged it in login.microsoft.com

Questions

  1. How can we get authenticate without enter the username & password in the login.microsoftonline.com

Is there way to bypass this login (like passing client,tenet, client secret id as parameter to login.microsoft.com) or any REST API?

We are using separate login for application so we will have to use two login

  1. Application login
  2. login.microsoft.com for Dynamics CRM
1
Sounds like you are interested in an Application User. This article may help.Aron

1 Answers

0
votes

Web API authentication patterns There are three different ways to manage authentication when using the Web API.

With JavaScript in web resources When you use the Web API with JavaScript within HTML web resources, form scripts, or ribbon commands you don’t need to include any code for authentication. In each of these cases the user is already authenticated by the application and authentication is managed by the application.

With on-premises deployments When you use the Web API for on-premises deployments you must include the user’s network credentials. The following example is a C# function that will return an HttpClient configured for a given user’s network credentials:

private HttpClient getNewHttpClient(string userName,string password,string domainName, string webAPIBaseAddress)
{
    HttpClient client = new HttpClient(new HttpClientHandler() { Credentials = new NetworkCredential(userName, password, domainName) });
    client.BaseAddress = new Uri(webAPIBaseAddress);
    client.Timeout = new TimeSpan(0, 2, 0);
    return client;
}

With Microsoft Dynamics 365 (online) or internet facing deployments When you use the Web API for Dynamics 365 (online) or an on-premises Internet-facing deployment (IFD) you must use OAuth as described in Connect to Microsoft Dynamics 365 web services using OAuth.

If you’re creating a single page application (SPA) using JavaScript you can use the adal.js library as described in Use OAuth with Cross-Origin Resource Sharing to connect a Single Page Application to Microsoft Dynamics 365.

https://msdn.microsoft.com/en-us/library/mt595798.aspx