microsoft-authentication-library-for-dotnet: COMException calling PublicClientApplication.AcquireTokenSilentAsync

Which Version of MSAL are you using ? MSAL 2.0.0-preview

Which platform has the issue? UWP

What authentication flow has the issue?

  • Desktop
    • Interactive

Repro

string[] Scopes = new[] { "User.Read", "Files.ReadWrite.AppFolder", "Files.Read.All" };
PublicClientApplication app = new PublicClientApplication(ServiceApiKeys.MsalClientId) { RedirectUri = ServiceApiKeys.MsalClientRedirectUri };
AuthenticationResult auth = await app.AcquireTokenAsync(Scopes, null);

Expected behavior I’d expect this to work, as it did in 1.1.4-preview0002.

Actual behavior When signing in with an MSA, I see the following exception:

    System.Runtime.InteropServices.COMException: 'The length of the state manager setting name has exceeded the limit.

Error trying to write application data container value'

   at System.Runtime.InteropServices.WindowsRuntime.IMap`2.Insert(K key, V value)
   at System.Runtime.InteropServices.WindowsRuntime.MapToDictionaryAdapter.Insert[K,V](IMap`2 _this, K key, V value)
   at System.Runtime.InteropServices.WindowsRuntime.MapToDictionaryAdapter.Indexer_Set[K,V](K key, V value)
   at Microsoft.Identity.Core.Telemetry.TelemetryTokenCacheAccessor.SaveAccessToken(MsalAccessTokenCacheItem item, RequestContext requestContext)
   at Microsoft.Identity.Client.TokenCache.SaveAccessAndRefreshToken(AuthenticationRequestParameters requestParams, MsalTokenResponse response)
   at Microsoft.Identity.Client.Internal.Requests.RequestBase.SaveTokenResponseToCache()
   at Microsoft.Identity.Client.Internal.Requests.RequestBase.PostTokenRequest()
   at Microsoft.Identity.Client.Internal.Requests.RequestBase.<RunAsync>d__35.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Client.PublicClientApplication.<AcquireTokenForLoginHintCommonAsync>d__22.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Identity.Client.PublicClientApplication.<AcquireTokenAsync>d__14.MoveNext()

I’ve tried this with two different MSAs (an outlook.com email address and a private domain email address) and both have the same problem.

Additional context/ Logs / Screenshots Another issue: when upgrading from 1.1.4-preview0002, the previously signed-in user is no longer available in PublicClientApplication.GetAccountsAsync(). This is annoying because apps using your library will need to ask their users to sign in again. Please migrate data from previous versions.

Also: having the name of the user on IUser was useful. What is the equivalent on IAccount?

Thanks.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

We have a fix and expect to hot fix this issue soon.

Thanks for your reply!

That’s unfortunate about upgrades from previous releases of MSAL.

Because of the COMException I never managed to obtain a working instance of IAccount. Hopefully it’ll have what I need.

Any ideas on the exception?