Skip to content

[Bug] unknown_broker_error when click "Only used for Microsoft app" link. #5705

@LKMMKL

Description

@LKMMKL

Library version used

4.64.1

.NET version

.NET Franewirk 4.7.2

Scenario

PublicClient - desktop app

Is this a new or an existing app?

The app is in production, I haven't upgraded MSAL, but started seeing this issue

Issue description and reproduction steps

In a new machine which never login by MSAL.
During login process, click "Only used for Microsoft app" link, process interrupted and throw "unknown_broker_error".
After login failure, the same account cannot be successfully logged in for a period of time.
If this operation is performed on a machine that has already logged into the account, the probability of recurrence is low.

Image Image

Relevant code snippets

_currentUserAccount = _currentUserAccount ?? (await otApp.GetAccountsAsync()).FirstOrDefault();
if (_currentUserAccount == null)
{
    _currentUserAccount = Microsoft.Identity.Client.PublicClientApplication.OperatingSystemAccount;
}
try
{
    if (!Controller.reLogin)
    {
        authResult = await otApp.AcquireTokenSilent(scopes, _currentUserAccount)
        .ExecuteAsync();
    }
}
catch (MsalUiRequiredException ex)
{

    var cancelToken = new CancellationTokenSource();
    cancelToken.CancelAfter(TimeSpan.FromMinutes(timeOut));

    IntPtr browserHandle = FindWindow(null, info.appName);
    try
    {
        authResult = await otApp.AcquireTokenInteractive(scopes)
                            .WithParentActivityOrWindow(browserHandle)
                            .WithPrompt(Microsoft.Identity.Client.Prompt.SelectAccount)
                            
                            .ExecuteAsync(cancelToken.Token);
        
    }
    catch{}
}

Expected behavior

Complete login normally.

Identity provider

Microsoft Entra ID (Work and School accounts and Personal Microsoft accounts)

Regression

No response

Solution and workarounds

No response

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions