microsoft-authentication-library-for-dotnet: [Bug] The same command was already received and is being processed.
Logs and network traces
Info 16-7-2021 15:39:10 +02:00 MsAuthStartActivity [OnCreate:93]Start sign in. Reason: app started
Debug 16-7-2021 15:39:10 +02:00 MsAuthStartActivity [StartSignIn:126]MijnOmgeving is not installed
Debug 16-7-2021 15:39:10 +02:00 AzureAdAuthenticationContext [SetContext:40]Setting context: ComponentInfo{nl.servicewal/md5e028ef4bf28caaffe48d2e3e854927ae.StartActivity}
Info 16-7-2021 15:39:10 +02:00 MsAuthStartActivity [SignInForEnvironmentAsync:170]Sign in for environment Productie
Debug 16-7-2021 15:39:10 +02:00 AzureAdAuthenticationContext [SetContext:40]Setting context: ComponentInfo{nl.servicewal/md5e028ef4bf28caaffe48d2e3e854927ae.StartActivity}
Info 16-7-2021 15:39:10 +02:00 AzureAdAuthService [SignInAsync:52]Attempting to sign in silently
Debug 16-7-2021 15:39:10 +02:00 AzureAdAuthService [RequestTokenSilentWithTimeoutAsync:78]Starting silent token request
Debug 16-7-2021 15:39:10 +02:00 AzureAdAuthTokenProvider [RequestTokenSilentAsync:112]Request silent token has username: True and with scopes: *** edited: SCOPE 2 ***
Debug 16-7-2021 15:39:10 +02:00 MsAuthStartActivity [OnActivityResult:353]Activity returned: [RequestCode: 1200][ResultCode: Canceled]
Info 16-7-2021 15:39:10 +02:00 AzureAdAuthTokenProvider [RequestTokenSilentAsync:119]Silent sign in started
Debug 16-7-2021 15:39:10 +02:00 AzureAdAuthTokenProvider [RequestTokenSilentAsync:166]Request silent token with TokenSource: Cache
Debug 16-7-2021 15:39:10 +02:00 AzureAdAuthService [RequestTokenSilentWithTimeoutAsync:108]Finished silent token request
Info 16-7-2021 15:39:10 +02:00 AzureAdAuthService [SignInAsync:56]Silent sign in success.
Debug 16-7-2021 15:39:10 +02:00 MsAuthStartActivity [SignInForEnvironmentAsync:181]Go to main activity, the user logged in
Info 16-7-2021 15:39:10 +02:00 MsAuthStartActivity [SignInForEnvironmentAsync:253]SignInForEnvironmentAsync finished
Info 16-7-2021 15:39:10 +02:00 AzureAdAuthService [SignInAsync:52]Attempting to sign in silently
Debug 16-7-2021 15:39:10 +02:00 AzureAdAuthService [RequestTokenSilentWithTimeoutAsync:78]Starting silent token request
Debug 16-7-2021 15:39:10 +02:00 AzureAdAuthTokenProvider [RequestTokenSilentAsync:112]Request silent token has username: True and with scopes: *** edited: SCOPE 1 ***
Info 16-7-2021 15:39:10 +02:00 AzureAdAuthTokenProvider [RequestTokenSilentAsync:119]Silent sign in started
Warning 16-7-2021 15:39:10 +02:00 AzureAdAuthTokenProvider [MsalLoggingCallback:195]MSAL: Warning (False) MSAL 4.30.1.0 MSAL.Xamarin.Android 26 [07/16/2021 13:39:10 - ] Refreshing the RT failed. Is AAD down? False. Is there an AT in the cache that is usable? False
Warning 16-7-2021 15:39:10 +02:00 AzureAdAuthTokenProvider [MsalLoggingCallback:195]MSAL: Warning (False) MSAL 4.30.1.0 MSAL.Xamarin.Android 26 [07/16/2021 13:39:10 - ] Failed to refresh the RT and cannot use existing AT (expired or missing).
Debug 16-7-2021 15:39:11 +02:00 AzureAdAuthenticationContext [SetContext:40]Setting context: ComponentInfo{nl.servicewal/crc64d0f81eb6dd67911c.ServiceWalActivity}
Info 16-7-2021 15:39:11 +02:00 AzureAdAuthService [SignInAsync:52]Attempting to sign in silently
Debug 16-7-2021 15:39:11 +02:00 AzureAdAuthService [RequestTokenSilentWithTimeoutAsync:78]Starting silent token request
Debug 16-7-2021 15:39:11 +02:00 AzureAdAuthTokenProvider [RequestTokenSilentAsync:112]Request silent token has username: True and with scopes: *** edited: SCOPE 2 ***
Info 16-7-2021 15:39:11 +02:00 AzureAdAuthTokenProvider [RequestTokenSilentAsync:119]Silent sign in started
Info 16-7-2021 15:39:11 +02:00 AzureAdAuthService [SignInAsync:52]Attempting to sign in silently
Debug 16-7-2021 15:39:11 +02:00 AzureAdAuthService [RequestTokenSilentWithTimeoutAsync:78]Starting silent token request
Debug 16-7-2021 15:39:11 +02:00 AzureAdAuthTokenProvider [RequestTokenSilentAsync:112]Request silent token has username: True and with scopes: *** edited: SCOPE 1 ***
Info 16-7-2021 15:39:11 +02:00 AzureAdAuthTokenProvider [RequestTokenSilentAsync:119]Silent sign in started
Warning 16-7-2021 15:39:11 +02:00 AzureAdAuthTokenProvider [MsalLoggingCallback:195]MSAL: Warning (False) MSAL 4.30.1.0 MSAL.Xamarin.Android 26 [07/16/2021 13:39:11 - ] Refreshing the RT failed. Is AAD down? False. Is there an AT in the cache that is usable? False
Warning 16-7-2021 15:39:11 +02:00 AzureAdAuthTokenProvider [MsalLoggingCallback:195]MSAL: Warning (False) MSAL 4.30.1.0 MSAL.Xamarin.Android 26 [07/16/2021 13:39:11 - ] Failed to refresh the RT and cannot use existing AT (expired or missing).
Debug 16-7-2021 15:39:11 +02:00 AzureAdAuthTokenProvider [RequestTokenSilentAsync:166]Request silent token with TokenSource: Cache
Debug 16-7-2021 15:39:11 +02:00 AzureAdAuthService [RequestTokenSilentWithTimeoutAsync:108]Finished silent token request
Info 16-7-2021 15:39:11 +02:00 AzureAdAuthService [SignInAsync:56]Silent sign in success.
Warning 16-7-2021 15:39:11 +02:00 AzureAdAuthTokenProvider [MsalLoggingCallback:195]MSAL: Warning (False) MSAL 4.30.1.0 MSAL.Xamarin.Android 26 [07/16/2021 13:39:11] [Android broker] Silent call failed. This usually means that the RT cannot be refreshed and interaction is required. BundleResult: Bundle[{broker_result_v2={"cached_at":0,"broker_error_code":"duplicate_command","broker_error_message":"The same command was already received and is being processed.","broker_exception_type":"com.microsoft.identity.common.exception.ClientException","expires_on":0,"ext_expires_on":0,"http_response_code":0,"serviced_from_cache":false,"success":false}, broker_request_v2_success=false}] Result string: {"cached_at":0,"broker_error_code":"duplicate_command","broker_error_message":"The same command was already received and is being processed.","broker_exception_type":"com.microsoft.identity.common.exception.ClientException","expires_on":0,"ext_expires_on":0,"http_response_code":0,"serviced_from_cache":false,"success":false}
Error 16-7-2021 15:39:11 +02:00 AzureAdAuthTokenProvider [MsalLoggingCallback:195]MSAL: Error (False) MSAL 4.30.1.0 MSAL.Xamarin.Android 26 [07/16/2021 13:39:11 - ] Exception type: Microsoft.Identity.Client.MsalServiceException
, ErrorCode: duplicate_command
HTTP StatusCode 0
CorrelationId
at Microsoft.Identity.Client.Internal.Requests.BrokerSilentStrategy.ValidateResponseFromBroker (Microsoft.Identity.Client.OAuth2.MsalTokenResponse msalTokenResponse) [0x000d3] in <4b3e46bb0945484e8c26e9b1d61cef82>:0
at Microsoft.Identity.Client.Internal.Requests.BrokerSilentStrategy.SendTokenRequestToBrokerAsync () [0x0013a] in <4b3e46bb0945484e8c26e9b1d61cef82>:0
at Microsoft.Identity.Client.Internal.Requests.BrokerSilentStrategy.ExecuteAsync (System.Threading.CancellationToken cancellationToken) [0x00079] in <4b3e46bb0945484e8c26e9b1d61cef82>:0
at Microsoft.Identity.Client.Internal.Requests.Silent.SilentRequest.ExecuteAsync (System.Threading.CancellationToken cancellationToken) [0x00235] in <4b3e46bb0945484e8c26e9b1d61cef82>:0
at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync (System.Threading.CancellationToken cancellationToken) [0x000fb] in <4b3e46bb0945484e8c26e9b1d61cef82>:0
Error 16-7-2021 15:39:11 +02:00 MsalServiceException [RequestTokenSilentAsync:132]MSAL.Xamarin.Android.4.30.1.0.MsalServiceException:
ErrorCode: duplicate_command
Microsoft.Identity.Client.MsalServiceException: Broker response returned error: The same command was already received and is being processed.
at Microsoft.Identity.Client.Internal.Requests.BrokerSilentStrategy.ValidateResponseFromBroker (Microsoft.Identity.Client.OAuth2.MsalTokenResponse msalTokenResponse) [0x000d3] in <4b3e46bb0945484e8c26e9b1d61cef82>:0
at Microsoft.Identity.Client.Internal.Requests.BrokerSilentStrategy.SendTokenRequestToBrokerAsync () [0x0013a] in <4b3e46bb0945484e8c26e9b1d61cef82>:0
at Microsoft.Identity.Client.Internal.Requests.BrokerSilentStrategy.ExecuteAsync (System.Threading.CancellationToken cancellationToken) [0x00079] in <4b3e46bb0945484e8c26e9b1d61cef82>:0
at Microsoft.Identity.Client.Internal.Requests.Silent.SilentRequest.ExecuteAsync (System.Threading.CancellationToken cancellationToken) [0x00235] in <4b3e46bb0945484e8c26e9b1d61cef82>:0
at Microsoft.Identity.Client.Internal.Requests.RequestBase.RunAsync (System.Threading.CancellationToken cancellationToken) [0x0016a] in <4b3e46bb0945484e8c26e9b1d61cef82>:0
at Microsoft.Identity.Client.ApiConfig.Executors.ClientApplicationBaseExecutor.ExecuteAsync (Microsoft.Identity.Client.ApiConfig.Parameters.AcquireTokenCommonParameters commonParameters, Microsoft.Identity.Client.ApiConfig.Parameters.AcquireTokenSilentParameters silentParameters, System.Threading.CancellationToken cancellationToken) [0x000d5] in <4b3e46bb0945484e8c26e9b1d61cef82>:0
at Ns.Orp.Auth.AzureAd.Droid.Services.AzureAdAuthTokenProvider.RequestTokenSilentAsync (System.Collections.Generic.IEnumerable`1[T] scopes, Microsoft.Identity.Client.IAccount account, System.Threading.CancellationToken cancellationToken) [0x0008e] in <a390da5a228e401b980a0a3228d09177>:0
at Ns.Orp.Auth.AzureAd.Droid.Services.AzureAdAuthTokenProvider.RequestTokenSilentAsync (System.Collections.Generic.IEnumerable`1[T] scopes, System.String username, System.Threading.CancellationToken cancellationToken) [0x0016b] in <a390da5a228e401b980a0a3228d09177>:0
StatusCode: 0
ResponseBody:
Headers:
Which version of MSAL.NET are you using? 4.30.1
Platform Xamarin.Android
What authentication flow has the issue?
- Desktop / Mobile
- Interactive
- Integrated Windows Authentication
- Username Password
- Device code flow (browserless)
- Web app
- Authorization code
- On-Behalf-Of
- Daemon app
- Service to Service calls
Is this a new or existing app? b. The app is in production, I haven’t upgraded MSAL, but started seeing this issue.
Repro We have several mobile apps that use Authenticator as a broker. We experience that some of our users unexpectedly have to log in again (interactive flow) for unknown reasons. One of the errors we see in the logging is: “Microsoft.Identity.Client.MsalServiceException: Broker response returned error: The same command was already received and is being processed."
Expected behavior We expect that the user will only have to log in interactively after a password change.
About this issue
- Original URL
- State: closed
- Created 3 years ago
- Comments: 18 (4 by maintainers)
I wonder if this is really an external issue. Seems like you cannot call AcquireTokenSilent several times when talking to Authenticator. I think in MSAL we can add a semaphore around this.
The workaround seems to do the trick. Hope you will fix it soon.
We will try a workaround for now (SemaphoreSlim lock around acquire token silent) because when acquiring token silent fails the method acquire token interactive is being called which is not what we want to happen in this scenario…
Thank you for your response. It’s difficult for us, because we have about 10k users that we don’t have direct contact with. In addition, due to privacy, we do not see any employee data in the logging, so we cannot contact them about this error. I will consult with my colleagues to consider how we can obtain the relevant broker incident id’s.
It happens on Android 8, 9, 10 & 11 and on multiple devices like Galaxy A8 (2018), Galaxy S7, Galaxy S9, Galaxy A50. Our users have the most recent version of Authenticator.