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 :
Microsoft Dynamics 365 | Integration, Dataverse...
Unanswered

Migrating from AuthType Office365 to OAuth

(0) ShareShare
ReportReport
Posted on by 8

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

 

   

I have the same question (0)
  • Power Platform Communities Profile Picture
    8 on at

    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

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 > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Martin Dráb Profile Picture

Martin Dráb 41 Most Valuable Professional

#2
iampranjal Profile Picture

iampranjal 39

#3
Satyam Prakash Profile Picture

Satyam Prakash 35

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans