I have been using AuthType as Office365 for my applications that communicates with Dynamics Crm, but since it is deprecated I have replace my connectionstring as follows:
Old:
<add key="CrmConnectionString" value="AuthType=Office365;Url=https://myenvironment. crm11.dynamics.com/;Username=myuseraccount@test.onmicrosoft.com;Password=Pa55word"/>
New:
<add key="CrmConnectionString" value="AuthType=OAuth;Username= myuseraccount@test.onmicrosoft.com; Password=Pa55word;Url= myenvironment.crm11.dynamics.com;AppId=51f81489-12ee-4a9e-aaae-a2591f45987d; RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;LoginPrompt=Never"/>
This works fine using the above default AppId and RedirectUri that Microsoft has provided. But I want to use my own AppId and therefore I created App Registration in Azure with all the configuration settings given in Microsoft doc Tutorial: Register an app with Azure Active Directory (Microsoft Dataverse) - Power Apps | Microsoft Docs.
I have replaced the AppId above with my AppId in Azure and has no RedirectUri so I left that blank. The code I am using is below:
CrmServiceClient conn = new CrmServiceClient(System.Configuration.ConfigurationManager.ConnectionStrings["MyCrm"].ConnectionString);
IOrganizationService orgService = (IOrganizationService)conn;
I am using Microsoft.CrmSdk.XrmTooling.CoreAssembly version 9.1.0.79
So when I try to create the connection, it throws the following error:
ERROR REQUESTING Token FROM THE Authentication context - General ADAL Error
AADSTS7000218: The request body must contain the following parameter: 'client_assertion' or 'client_secret'.
Trace ID: b901ed4b-bce4-44db-b20c-379317e52001
Correlation ID: ad84567a-99ac-4f02-b966-42f4f20642e7
Do I need anything else in connectionstring or the code? I don't want to use the ClientSecret Authtype because I need to pass the userid who will be talking to Crm.
Please suggest.