We have a new community! Please visit support.timextender.com
Follow

Connect to Dynamics 365 Sales (CRM Online)

TimeXtender can connect and extract data from a Dynamics 365 Sales instance using the CData Dynamics 365 Sales ADO.NET Provider. You may find more information on using this provider from the CData Provider Help Guide here

This guide is broken down into multiple steps:

  1. Create an App Registration in Azure Active Directory
    1. Create the App Registration
    2. Create the App Secret
    3. Add the API Permission
  2. Add the Data Source in TimeXtender
    1. Configure the Data Source Connection
      1. Use the Client Credentials method

Create an App Registration in Azure Active Directory

For Dynamics 365 to authenticate a connection from an external application, you must first create an App Registration in Azure Active Directory. You can learn more about this process from Microsoft here, however, more direct steps are provided below. 

Create the App Registration

  1. In the Azure Portal, navigate to Azure Active Directory
  2. Select App Registrations in the menu bar on the left & Select New Registration.       
  3. Enter a name and select Accounts in any organizational directory (Multitenant).
  4. Enter a redirect URI, This can be something generic like (http://localhost:33333) or you may use your Organizational URL for your Dynamics instance (https://<company>.crm4.dynamics.com/).
  5. Select Register when you are done.
  6. Note down the Application ID which will be used later.

Create the App Secret

  1. After creating the App Registration, select Certificates & secrets.
  2. Select New Client Secret.
  3. Provide a description of the secret, and a duration. When done, select Add. (This key is encrypted after save, so it needs to be documented somewhere safe.)
  4. Note down the Client Secret Value which will be used later.

Add the API Permission

  1. Under the App Registration menu Select API Permissions.
  2. Select Add a permission
  3. Under Microsoft APIs, select Dynamics CRM
  4. Select Delegated permissions, then select user_impersonation, & click Add permissions

2021-02-18_14h01_13.png

The API permission should look like it appears in the red box above.

 

Add the Data Source in TimeXtender

This data source can be found by navigating to the Dynamics 365 Sales CData provider in the list of availabel CData providers either in the ODX or the Business Unit.

Once you have added the data source configure the connection values as described below

Configure the Data Source Connection

  1. Enter your Organization URL for you Dynamics Instance. This should appear similar to https://<company>.crm4.dynamics.com/.
  2. Scroll down to the OAuth section of connection string options and set Initiate OAuth to REFRESH
  3. Set the OAuth Client Id to the Application ID of the App Registration created earlier. 
  4. Set the OAuth Client Secret to the Client Secret of the App Registration created earlier.
  5. Click the Authorize OAuth button. This should launch a web browser and authorize your connection to Dynamics. 
  6. Add a specific OAuth Settings Location path to the file instead of the default. It works fine for testing, but when using scheduled executions in a BU the file will not exist for the service to use.

  7. Click the Test Connection button to ensure you have connected successfully. 

mceclip0.png

Use the Client Credentials method

You also have the options of using Client credentials to gain access.

Client Credentials

Client credentials refers to a flow in OAuth where there is no direct user authentication taking place. Instead, credentials are created for just the app itself. All tasks taken by the app are done without a default user context. This makes the authentication flow a bit different from standard.

Client OAuth Flow

All permissions related to the client oauth flow require admin consent. This means the app embedded with the CData ADO.NET Provider for Dynamics 365 Sales cannot be used in the client oauth flow. You must create your own OAuth app in order to use client credentials. See Creating a Custom OAuth App for more details.

In your App Registration in portal.azure.com, navigate to API Permissions and select the Microsoft Graph permissions. There are two distinct sets of permissions - Delegated and Application permissions. The permissions used during client credential authentication are under Application Permissions. Select the applicable permissions you require for your integration.

In addition to setting the standard OAuth client id and secret, to use client credentials you must also set the following connection properties:

  • OAuthGrantType: Set this to CLIENT.
  • AzureTenant: Set this to the tenant you wish to connect to.

When you authenticate using client credentials, there is no Web flow. Authentication with client credentials will take place automatically like any other connection, except there will be no window opened prompting the user. Because there is no user context, there is no need for a browser popup. Connections will take place and be handled internally.

Was this article helpful?
1 out of 1 found this helpful

0 Comments

Please sign in to leave a comment.