Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Migrating from AuthType Office365 to OAuth

(0) ShareShare
ReportReport
Posted on by 4

As part of an existing application that connects to our Dynamics 365 instance we are currently trying to modify our existing code at the recommendation of Microsoft based on article https://docs.microsoft.com/en-us/powerapps/developer/data-platform/authenticate-office365-deprecation to utilize OAuth .  The article provides a connection string example of: 

connectionString = "AuthType=OAuth;Username=jsmith@contoso.onmicrosoft.com; Password=passcode;Url=contosotest.crm.dynamics.com;AppId=51f81489-12ee-4a9e-aaae-a2591f45987d; RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;LoginPrompt=Auto"

 which allows me to successfully sign-in when I substitute our organization's Username and password however when I execute:

System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12;
using (var svc = new CrmServiceClient(conn))
{
Guid g = svc.ConnectedOrgId;
WhoAmIRequest request = new WhoAmIRequest();

WhoAmIResponse response = (WhoAmIResponse)svc.Execute(request);

Console.WriteLine("Your UserId is {0}", response.UserId);

Console.WriteLine("Press any key to exit.");
Console.ReadLine();
}

The Organization ID that is returned is 00000000-0000-0000-0000-000000000000 and the response is a null object.  I chalk this up to the use of the sample AppIDs.  After substituting for our AppID and Organization url found in our instance settings however we're still getting the same results.  Based on the information I've researched it appears our application needs to be registered in Azure AD.  I'm utilizing information at https://docs.microsoft.com/en-us/powerapps/developer/data-platform/use-single-tenant-server-server-authentication however that appears to be for registering a new application.  We're trying to add Azure AD for an existing Dynamics 365 application ported from an on-prem instance back in 2018.  Is there any guidance for utilizing OAuth for older applications?

 

ddeputy_0-1624568801545.png

 

   

  • Power Platform Communities Profile Picture
    4 on at
    RE: Migrating from AuthType Office365 to OAuth

    I think you are on the right track. You need the app registration, so you can give this app the consent to connect to your existing d365 environment.

    Don’t forget to create an application user in d365 and ty it up to the azure app (client I’d)

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

News and Announcements

Now Available: 2025 Release Wave 2

Quick Links

Ramesh Kumar – Community Spotlight

We are honored to recognize Ramesh Kumar as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Adis Profile Picture

Adis 136 Super User 2025 Season 1

#2
Sohail Ahmed Profile Picture

Sohail Ahmed 81

#3
Jonas "Jones" Melgaard Profile Picture

Jonas "Jones" Melgaard 77 Super User 2025 Season 1

Product updates

Dynamics 365 release plans