question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

COMException calling PublicClientApplication.AcquireTokenSilentAsync

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:16 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
bgavrilMScommented, Oct 2, 2018

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

1reaction
mfeingolcommented, Sep 10, 2018

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?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does my application always end up calling Program. ...
I need to review the answer provided: you need to implement a token cache and use AcquireTokenSilentAsync. https://learn.microsoft.com/en-us/ ...
Read more >
Migrate public client applications to MSAL.NET
Learn how to migrate a public client application from Azure Active Directory ... In this case, we replace the call to AuthenticationContext.
Read more >
WPF Application with Microsoft Graph API - Office 365 University
In this article, I am going to select WPF application and connect with Graph API. The purpose of connecting with Graph API is...
Read more >
How to log in only once using Graph API?
// A MsalUiRequiredException happened on AcquireTokenSilentAsync. This indicates you need to call AcquireTokenAsync to acquire a token; Debug.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found