Skip to main content

Notifications

Customer experience | Sales, Customer Insights,...
Answered

Client Secret Connection String for SDK Access

Posted on by 30

Hello all,

I'm trying to connect to Dynamics 365 Online through the SDK / C#. For that, I have created an application in the AD. Through XRMToolbox, I'm perfectly able to connect to the CRM, through the ClientSecret wizard and connection string. However, once I'm trying to use Microsoft.Xrm.Tooling.Connector.CrmServiceClient with the same connection string, I get an error stating that the authority can't be null.

Screenshot-2020_2D00_03_2D00_23-at-08.14.44.png

ClientSecret Authentication should be supported in Xrm.Tooling.Connector since September, does anybody have experience with it?

Details:

Connectionstring used:  "AuthType=ClientSecret;domain=">login.microsoftonline.com/.../xxx.crm4.dynamics.com;ClientId=xxxxxxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx;ClientSecret=<secret>";
Also tried directly: 
var serviceClient = new Microsoft.Xrm.Tooling.Connector.CrmServiceClient(new System.Uri("">xxxx.crm4.dynamics.com"), <client ID>, <client secret>, false, "c:\\Temp\\Oauth\\cache.txt");

I also can't use the AuthenticationContext method since that requires async methods. Unfortunately, I don't know how to use that with my WCF webservice.

Thanks!

  • manuBF Profile Picture
    manuBF 30 on at
    RE: Client Secret Connection String for SDK Access

    Hi Koji,

    Thank you very much for your answer! Fortunately, I was able to find the error. It wasn't the connection string, but instead:

    I used Visual Studio 2015 to debug my WCF Service. Even though I specified .NET 4.8, the internal Debug engine compiles everything against .NET 4.5. Now, Dynamics 365 requires TLS1.2 for connections, otherwise they get rejected. TLS 1.2 is supported from Version 4.7 onwards, but not in .NET 4.5.

    So in conclusion: The connection string was fine, but I should have also updated the IDE instead of only packages and Framework. The error messages I received were arbitrary errors that result from the rejected connections.

    Thanks for your help!

  • Verified answer
    kojisaiki Profile Picture
    kojisaiki on at
    RE: Client Secret Connection String for SDK Access

    Does connection string with username and password as below work?

    "Url=contoso.crm.dynamics.com; Username=someone@contoso.onmicrosoft.com; Password=password; authtype=Office365"

    From: docs.microsoft.com/.../sample-simplified-connection-quick-start

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans