Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Power Apps Pro Dev & ISV
Unanswered

Microsoft.PowerPlatform.Dataverse.Client.ServiceClient OAuth login fails for .NET 6.0

(0) ShareShare
ReportReport
Posted on by 6

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.

  • MattB-MSFT Profile Picture
    Microsoft Employee on at
    Re: Microsoft.PowerPlatform.Dataverse.Client.ServiceClient OAuth login fails for .NET 6.0

    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. 

     

  • cchannon Profile Picture
    4,702 Super User 2025 Season 1 on at
    Re: Microsoft.PowerPlatform.Dataverse.Client.ServiceClient OAuth login fails for .NET 6.0

    Tagging @MattB-MSFT because this is also ServiceClient related, but it does seem like more of an MSAL issue than ServiceClient.

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Power Apps Pro Dev & ISV

#1
WarrenBelz Profile Picture

WarrenBelz 69 Most Valuable Professional

#2
mmbr1606 Profile Picture

mmbr1606 51 Super User 2025 Season 1

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 36

Overall leaderboard