Forum Discussion
Connect .Net (4.6.2) to Dataverse using the Dataverse plugin
Hi Microsoft Tech Community,
We have a Dataverse environment in our tenant, and I have its URL. I'm building a .NET application and need to connect it to Dataverse for data access.
From the Learn docs, ChatGPT, and Copilot, it seems I need to use an App ID (Client ID) and Client Secret in the connection string (e.g., via Microsoft.PowerPlatform.Dataverse.Client). However, the Dataverse environment itself doesn't expose any App ID or Client Secret—where would I even find those if they exist?
Here's the code snippet we found online that's using OAuth with AppId and RedirectUri, but we're unsure about the app registration part:
using Microsoft.Crm.Sdk.Messages;
using Microsoft.PowerPlatform.Dataverse.Client;
using Microsoft.Xrm.Sdk;
class Program
{
// TODO Enter your Dataverse environment's URL and logon info.
static string url = "https://yourorg.crm.dynamics.com";
static string userName = "email address removed for privacy reasons";
static string password = "yourPassword";
// This service connection string uses the info provided above.
// The AppId and RedirectUri are provided for sample code testing.
static string connectionString = $@"
AuthType = OAuth;
Url = {url};
UserName = {userName};
Password = {password};
AppId = 51f81489-12ee-4a9e-aaae-a2591f45987d;
RedirectUri = app://58145B91-0C36-4500-8554-080854F2AC97;
LoginPrompt=Auto;
RequireNewInstance = True";
static void Main()
{
//ServiceClient implements IOrganizationService interface
IOrganizationService service = new ServiceClient(connectionString);
var response = (WhoAmIResponse)service.Execute(new WhoAmIRequest());
Console.WriteLine($"User ID is {response.UserId}.");
// Pause the console so it does not close.
Console.WriteLine("Press the <Enter> key to exit.");
Console.ReadLine();
}
}Do I need to create a separate app registration in Microsoft Entra ID (Azure AD), link it to the Dataverse environment (perhaps as an application user?), and then use that app's Client ID/Secret in my .NET code? If so, could someone outline the exact steps, including permissions and Power Platform admin center setup?
Any guidance or links to official walkthroughs would be greatly appreciated—thanks!