microsoft-authentication-library-for-dotnet icon indicating copy to clipboard operation
microsoft-authentication-library-for-dotnet copied to clipboard

[Bug] Problem with new version 4.61.1

Open COMADD opened this issue 1 year ago • 1 comments

Library version used

4.61.1

.NET version

C# UWP

Scenario

PublicClient - desktop app

Is this a new or an existing app?

The app is in production, and I have upgraded to a new version of MSAL

Issue description and reproduction steps

Hello,

With the new version of the Microsoft.Identity.Client 4.61.1 package, I have a bug that has appeared. This bug is not present in version 4.60.3, nor previous ones.

When I try to acquire a token, I get the error message: Only loopback redirect uri is supported, but urn:ietf:wg:oauth:2.0:oob 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

Having not modified anything on my side, neither my code nor the Azure settings, I think this is a regression on your part!

Best regards

Relevant code snippets

PublicClientApplicationBuilder PCAB = PublicClientApplicationBuilder.Create(_clientId);
_IdentityClientApp = PCAB.Build();
IEnumerable<IAccount> accounts = await _IdentityClientApp.GetAccountsAsync();
AuthenticationResult authResult;
try
{
   authResult = await _IdentityClientApp.AcquireTokenSilent(scopes, accounts.FirstOrDefault()).ExecuteAsync();
}
catch (MsalUiRequiredException ex)
{
  Debug.WriteLine(ex.Message);
  authResult = await _IdentityClientApp.AcquireTokenInteractive(scopes).ExecuteAsync();
}

Expected behavior

I would like to acquire a token correctly.

Identity provider

Azure B2C Basic Policy

Regression

4.60.3

Solution and workarounds

Revert to version 4.60.3

COMADD avatar May 23 '24 08:05 COMADD

Hi @COMADD - we have dropped support for UWP, see https://devblogs.microsoft.com/identity/uwp-xamarin-msal-net-deprecation/

You app is now referencing MSAL netstandard, which will not work in a UWP environment.

We recommend you stay on 4.59.* and consider moving your app to WinUI

bgavrilMS avatar May 23 '24 08:05 bgavrilMS

@bgavrilMS We are facing the same issue even we are using .NET Maui and kind of same error

Only loopback redirect uri is supported, but msal{CLIENT_ID}://auth/ 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

I believe we cannot set localhost since we are using B2C and B2C doesn't support just localhost. Can you please confirm we can set any port with localhost or it needs to be specific or we are missing anything else since its already MAUI app

Arslan007 avatar May 26 '24 10:05 Arslan007

Please see https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/issues/4790 @Arslan007 . I would recommend staying on 4.60.0 for now, I have seen some strangeness on 4.60.1

bgavrilMS avatar May 31 '24 15:05 bgavrilMS

I experienced this same issue in our MAUI Windows app in .NET 8.0 using MSAL library for our B2C Tenant.

I have to back rev the Microsoft.Identity.Client library to 4.60.4

Will you be fixing this issue or not?

dmoon-aiq avatar Jun 27 '24 19:06 dmoon-aiq

@dmoon-aiq I have no issues with latest. You have to do three things for Windows

1- RedirectUI should be http://localhost 2- Add a reference to Microsoft.Identity.Client.Desktop and to Microsoft.Identity.Client.Extensions.Msal (same version as MSAL) 3- When you construct your PublicClientApplication add WithWindowsEmbeddedBrowserSupport()

Thats all it should work for you!

Arslan007 avatar Jun 27 '24 21:06 Arslan007

@Arslan007

I did not do Step 2.

But I used .WithEmbeddedWebViewOptions(new EmbeddedWebViewOptions()) and that seemed to work for me. I do not know if this is the same problem that was solved.

shripathi-kamath avatar Jul 10 '24 19:07 shripathi-kamath