Currently I am using NuGet package Microsoft.PowerPlatform.Dataverse.Client to connect to Dataverse from a console app. I have two console app versions, one on .NET 4.8 and one on .NET 6.0. Version 4.8 is working fine, but 6.0 fails when it attempts an OAuth login for an organization using a custom login page.
var client = new ServiceClient(@"AuthType=OAuth;AppId=51f81489-12ee-4a9e-aaae-a2591f45987d;RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;TokenCacheStorePath='C:\Data\token6.bin';Username=name@test.test;Url=https://companyname.crm4.dynamics.com/;LoginPrompt=Auto;");
This code fails with this exception:
Error at Microsoft.PowerPlatform.Dataverse.Client.Auth.AuthProcessor.ProcessMsalExecptionAsync(Uri serviceUrl, ClientCredentials clientCredentials, X509Certificate2 userCert, String clientId, Uri redirectUri, PromptBehavior promptBehavior, Boolean isOnPrem, String authority, Object msalAuthClient, DataverseTraceLogger logSink, Boolean useDefaultCreds, MemoryBackedTokenCache memoryBackedTokenCache, String tokenCacheStorePath, MsalException msalEx)
// (Microsoft.Identity.Client.MsalClientException: Only loopback redirect uri is supported, but app://58145b91-0c36-4500-8554-080854f2ac97/ was found. Configure http://localhost or http://localhost:port both during app registration and when you create the PublicClientApplication object. See https://aka.ms/msal-net-os-browser for details)
Again, the exact same code works perfectly fine on .NET 4.8. It also works on .NET 6.0 when a valid token is already present at the given location or when the organization does not use a customized login page, so my guess is the error is in the handling of custom login pages.
Redirect link on .net core for client apps is http://localhost. (Not https)
this is an msal thing, and it is documented on our docs for service client.
Tagging @MattB-MSFT because this is also ServiceClient related, but it does seem like more of an MSAL issue than ServiceClient.
WarrenBelz
69
Most Valuable Professional
mmbr1606
51
Super User 2025 Season 1
MS.Ragavendar
36