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

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

Error when trying to switch CrmServiceClient from the Office365 AuthType to OAuth AuthType

(0) ShareShare
ReportReport
Posted on by 5

So Im following this article to try and get our authentication switched over from Office365 to OAuth authentication because the Office365 auth type is deprecated: https://docs.microsoft.com/en-us/power-apps/developer/data-platform/authenticate-office365-deprecation#how-do-i-know-if-my-code-or-application-is-using-ws-trust

I have been trying various different connection strings for days now and i cant get this error to stop being thrown: "Unable to Login to Dynamics CRMOrganizationWebProxyClient is null"

This error isnt really helpful at all and i don't understand whats wrong. Here is my connection string:

AuthType=OAuth; Url=https://XXX.crm.dynamics.com; Username=XXXXXXXXXXX; Password=XXXXXXXXXXX; AppId=51f81489-12ee-4a9e-aaae-a2591f45987d; RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97; LoginPrompt=Never

And Here is how I'm using it in my C# application:

            System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;

            string crmConn = ConfigurationManager.ConnectionStrings["CRMConnection"].ConnectionString;


            var service = new CrmServiceClient(crmConn);
            return service;

But "service" always returns the above error. What am i doing wrong? How can i find a more useful error?

I have the same question (0)
  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    Have you tried updating the package to latest version?

    www.nuget.org/.../

    I created new console app and I use same code as yours and it works.

    You can download my project from below link and update config file with your credentials and URL.

    github.com/.../WorkWithCsharp

    Please mark my answer verified if this is helpful!

    Regards,

    Bipin Kumar

    Follow my Blog: xrmdynamicscrm.wordpress.com/

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi,

    Just follow the step.

    Downloads the latest version of 

    • using Microsoft.PowerPlatform.Dataverse.Client;
    • using Microsoft.Xrm.Sdk;

    Just follow the below program 

    • public static void Connect()
    •         {
    •             //  log.LogInformation("C# HTTP trigger function processed a request.");
    •             ServiceClient crmServiceClient = null;
    •             System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
    •             var clientId = "8182544c-3485-4bc3-9884-81617d48e39a";
    •             var clientSecret = "8jm7Q~nhPHGP0Ccl-6a5ow2Tivf4LzADLdZMR";
    •             var organizationUrl = "">org13ffb2c4.crm8.dynamics.com/";
    •             string connectionString = "Url=" + organizationUrl + "; " +
    •             "AuthType=ClientSecret; " +
    •             "ClientId= " + clientId + "; " +
    •             "ClientSecret=" + clientSecret;
    •             crmServiceClient = new ServiceClient(connectionString);
    •             if (crmServiceClient.IsReady)
    •             {
    •                 CreateRecord(crmServiceClient);
    •             }
    •         }
    •         private static void CreateRecord(ServiceClient crmServiceClient)
    •         {
    •             try
    •             {
    •                 Entity newAccount = new Entity("account");
    •                 newAccount["name"] = "Account is crated through Azure";
    •                 crmServiceClient.Create(newAccount);
    •                 //Write the program here
    •             }
    •             catch (Exception)
    •             {
    •                 throw;
    •             }
    •         }

    Thanks ,

    Arshad 

    Please like and subscribe my YouTube Channel and follow my blog for latest interview question and answer.

    www.youtube.com/.../videos

    https://juniorcrmblog.blogspot.com/

    https://juniorazurecrm.blogspot.com/

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 83 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans