web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :

Dynamics CRM 365 Online Authenticate with Client Credentials

Varun Singh Profile Picture Varun Singh 943

Using Credentials (User name and password) to authenticate with Dynamics 365 CRM Online, can be a problem when executing long running background application processes that integrates with Dynamics CRM 365 Online.  As you know due to network polices user account or service account needs to update the password in regular frequencies.

Using authentication type Client Credentials for authentication with Dynamics 365 CRM Online will resolve this issue of using User Credentials which constantly changes and requires a Dynamics CRM 365 Online license. Client Credentials are made up of a client id and client secret which firstly need to be setup in Azure Portal. Once we have the client id and client secret, this can be used to obtain a bearer token. Here are the steps you would need to follow to authenticate using Client Credentials.

1. Register a App against Azure Active Directory 
 a) Log into https://portal.azure.com, navigate to Azure Active Directory -> App registrations and click on New application registration

image

b) Create the new App registration with Web app / API as the Application Type

image

image

c) Grant permissions to Dynamics CRM Online by navigating to Settings -> Required permissions. Click on Add and select Dynamics CRM Online

image

d) Select the following permissions then click Done

image

e) Dynamics CRM Online should now be added to the list of Required permissions. Click on Grant Permissions to complete the process
  image

f) Setup client secret key by navigating to Settings -> Keys, create a new Key and save to generate a new Secret key value

image

NOTE: Take note of the generated key value since it would not be visible the next time you navigate to the Keys List

2. Create a new Office 365 user
 a) Log into https://portal.office.com/adminportal, navigate to User -> Active users and click on Add a user

image

b) Fill in User details

image

c) Assign the Dynamics 365 Service Administrator Role

image

d). Apply the Dynamics 365 Product Licence and click Add

image

3. Create a new Dynamics 365 Application user
 a) Log into Dynamics 365 Online, navigate to Settings -> Security -> Users and change the view to Application Users. Click on New to open a new Application User Form

image

b) Fill in the following fields.
The value of the Application ID field will be the GUID value obtained from previous steps 1.

image

c) Once saving the record the following fields will be auto populated by Dynamics 365

image

4. Create new Security Role and assign to Application user
 a) Navigate to Settings -> Security -> Security Role and Copy the System Administrator Role

image

b) Name the new security role and completed the creation process

image

c)  Assign the new security role to the Application User

image

d) Remove Dynamics 365 license for the User in Office365 admin portal

image

5. Get Bearer Access Token by sending HTTP POST request to Token endpoint
The Token URL endpoint for any Dynamics CRM 365 Online would be https://login.microsoftonline.com/<tenant id>/oauth2/token

Obtain the tenant id from the Azure Portal

image

The body content of the HTTP Request will contain the following and will be URL encoded

image

A refresh token is not included as part of the response when using Client Credentials to authenticate, this is only available when authenticating using User Credentials.

So once the access token has been obtained then you can use this token in the Authorization header for all the request to Dynamics CRM 365 Online Web API.

Comments

*This post is locked for comments