[Bug] Microsoft.Identity.Client.MsalServiceException: Unknown Status: Unexpected - from terminal.
See original GitHub issueLogs and network traces MSAL.Desktop.4.48.1.0.MsalServiceException: ErrorCode: unknown_broker_error Microsoft.Identity.Client.MsalServiceException: Unknown Status: Unexpected Context: Missing wamcompat_id_token in WAM case Tag: 0x20714047 (error code 0) (internal error code 544292935) bei Microsoft.Identity.Client.Broker.WamAdapters.ThrowExceptionFromWamError(AuthResult authResult, AuthenticationRequestParameters authenticationRequestParameters, ILoggerAdapter logger) bei Microsoft.Identity.Client.Broker.WamAdapters.HandleResponse(AuthResult authResult, AuthenticationRequestParameters authenticationRequestParameters, ILoggerAdapter logger, String errorMessage) bei Microsoft.Identity.Client.Broker.RuntimeBroker.<SignInInteractivelyAsync>d__11.MoveNext() — Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde — bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei Microsoft.Identity.Client.Broker.RuntimeBroker.<AcquireTokenInteractiveAsync>d__10.MoveNext() — Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde — bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei Microsoft.Identity.Client.Internal.Broker.BrokerInteractiveRequestComponent.<FetchTokensAsync>d__9.MoveNext() — Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde — bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.<FetchTokensFromBrokerAsync>d__10.MoveNext() — Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde — bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.<GetTokenResponseAsync>d__11.MoveNext() — Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde — bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.<ExecuteAsync>d__9.MoveNext() — Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde — bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei Microsoft.Identity.Client.Internal.Requests.RequestBase.<RunAsync>d__12.MoveNext() — Ende der Stapelüberwachung vom vorhergehenden Ort, an dem die Ausnahme ausgelöst wurde — bei System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() bei System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) bei Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.<ExecuteAsync>d__2.MoveNext()
Which version of MSAL.NET are you using?
Platform .NET Framework 4.8 Desktop
What authentication flow has the issue?
- Desktop
- Interactive
- [ X] Integrated Windows Authentication
- [ X] Username Password
- Device code flow (browserless)
Is this a new or existing app? The app is in production, I haven’t upgraded MSAL, but started seeing this issue.
The customer start to expirencene login problems on his terminal-server. All his notebooks/workstation work without a problem.
Repro
private static void InitializePublicClientApplication(IWin32Window parent = null)
{
var clientAppId = UserSettings.Instance.AzureAppId;
var builder = PublicClientApplicationBuilder
.Create(clientAppId)
.WithAuthority(AadAuthorityAudience.AzureAdMultipleOrgs)
.WithExperimentalFeatures(true)
//.WithLogging(new MaslLogger(), enablePiiLogging: true)
.WithParentActivityOrWindow(() => parent)
.WithRedirectUri("ms-appx-web://microsoft.aad.brokerplugin/3932e83d-62c5-4f03-aaa9-7c6e86dbafad")
.WithBrokerPreview(true);
;
_ClientApp = builder.Build();
GraphTokenCacheHelper.EnableSerialization(_ClientApp.UserTokenCache);
RestoreContext();
}
protected async Task<AuthenticationResult> ForceUserLogin(
IEnumerable<string> scopes,
IEnumerable<string> additionalScopes,
IWin32Window parentWindow
)
{
try
{
if (parentWindow == null)
{
throw new ArgumentNullException(nameof(parentWindow));
}
var builder = ClientApp
.AcquireTokenInteractive(scopes)
.WithExtraScopesToConsent(additionalScopes)
.WithParentActivityOrWindow(parentWindow.Handle);
AuthenticationResult result = await builder.ExecuteAsync();
return result;
}
catch (MsalException ex)
{
LOG.ErrorToDefault($"ConnectionProviderBase.ForceUserLogin: Could not authenticate user in UI.", ex);
throw;
}
}
Expected behavior The force login method should generate a bearer-token and a refresh token for later use
Actual behavior The broker dialog display a success message, but the msal-library return a exception.
Additional context / logs / screenshots / links to code If the user chooses to the option “No, sign in to this app only”, we get the following error:
MSAL.Desktop.4.48.1.0.MsalUiRequiredException:
ErrorCode: failed_to_acquire_token_silently_from_broker
Microsoft.Identity.Client.MsalUiRequiredException: WAM Error
Error Code: 3399614467
Error Message: V2Error: invalid_grant AADSTS700082: The refresh token has expired due to inactivity. The token was issued on 2022-05-21T13:33:17.1657938Z and was inactive for 90.00:00:00.
Trace ID: 224ef9ce-2fcb-48e6-b259-c7d51fee2c00
Correlation ID: 5ba9596c-99da-4772-878d-aa644ddb7300
Timestamp: 2023-04-18 07:20:34Z
Internal Error Code: 558133255
Issue Analytics
- State:
- Created 5 months ago
- Reactions:1
- Comments:11 (5 by maintainers)
Top GitHub Comments
We will try and let you know. 😃
Hi, we have made significant changes in MSAL’s interaction with WAM in recent versions of MSAL.
Please upgrade to MSAL 4.53 and report back if the error persists. See https:\aka.ms\msal-net-wam