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.

[Bug] PlatformNotSupportedException in AcquireTokenInteractive call

See original GitHub issue

Which Version of MSAL are you using ? Note that to get help, you need to run the latest version. Preview version are also ok. For ADAL, please log issues to https://github.com/AzureAD/azure-activedirectory-library-for-dotnet

4.16.0 Platform

netstandard2.0 What authentication flow has the issue?

  • Desktop / Mobile
    • Interactive
    • Integrated Windows Auth
    • Username Password
    • Device code flow (browserless)
  • Web App
    • Authorization code
    • OBO
  • Web API
    • OBO

Other? - please describe;

Is this a new or existing app?

This is a new app or experiment Repro

 authResult = await app.AcquireTokenInteractive(scopes)
                .ExecuteAsync().ConfigureAwait(false);

Expected behavior A clear and concise description of what you expected to happen (or code). Interactive UI pop-up should show up for sign-in. Actual behavior A clear and concise description of what happens, e.g. exception is thrown, UI freezes
Following exception is thrown: System.PlatformNotSupportedException HResult=0x80131539 Message=Possible Cause: If you are using an XForms app, or generally a netstandard assembly, make sure you add a reference to Microsoft.Identity.Client.dll from each platform assembly (e.g. UWP, Android, iOS), not just from the common netstandard assembly Source=Microsoft.Identity.Client StackTrace: at Microsoft.Identity.Client.Platforms.netstandard13.WebUIFactory.CreateAuthenticationDialog(CoreUIParent parent, RequestContext requestContext) at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.CreateWebAuthenticationDialog() at Microsoft.Identity.Client.Internal.AuthCodeRequestComponent.<FetchAuthCodeAndPkceVerifierAsync>d__4.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.<GetTokenResponseAsync>d__11.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Identity.Client.Internal.Requests.InteractiveRequest.<ExecuteAsync>d__8.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Identity.Client.Internal.Requests.RequestBase.<RunAsync>d__14.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at Microsoft.Identity.Client.ApiConfig.Executors.PublicClientExecutor.<ExecuteAsync>d__2.MoveNext() at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1.ConfiguredTaskAwaiter.GetResult() at Microsoft.DevCanvas.Common.Providers.AuthZMsalProvider.<GetInteractiveFlowToken>d__2.MoveNext() in D:\devcanvas\Analyzers\Analyzers\Extensions\AuthZMsalProvider.cs:line 41

This exception was originally thrown at this call stack: [External Code] Microsoft.DevCanvas.Common.Providers.AuthZMsalProvider.GetInteractiveFlowToken() in AuthZMsalProvider.cs

Possible Solution

Additional context/ Logs / Screenshots Add any other context about the problem here, such as logs and screebshots. Logging is described at https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/logging

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
bgavrilMScommented, Nov 8, 2021

Hi @ShaneOss - for mobile plantforms and UWP, MSAL takes care of the token cache for you:

  • on UWP it stores in it encrypted at rest (with DPAPI) in a file
  • on iOS it stores it in KeyChain
  • on Android in SharedPreferences

On other runtimes, we ask developers to define where the cache is stored etc.

https://docs.microsoft.com/en-us/azure/active-directory/develop/msal-net-token-cache-serialization?tabs=mobile

0reactions
bgavrilMScommented, Mar 15, 2022

I do not recommed it, it will not be easy to implement. Let’s continue the discussion on Discussions tab.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Desktop app that calls web APIs: Acquire a token interactively
On Windows, you must call AcquireTokenInteractive from the UI thread so that the embedded browser gets the appropriate UI synchronization ...
Read more >
c# - When Calling from within a Unity App, What to Put for ...
When Calling from within a Unity App, What to Put for Parent Object in MSAL's AcquireTokenInteractive? ... I'm trying to authenticate with MSAL ......
Read more >
How to Authenticate Through Azure Active Directory to use ...
Article covers how to implement client application authenticating through AAD to call the API of Business Central installation using the ...
Read more >
How to combine Graph & SharePoint permission consent ...
// A MsalUiRequiredException happened on AcquireTokenSilent. // This indicates you need to call AcquireTokenInteractive to acquire a token.
Read more >
Microsoft Authentication Library 4.54.0 Supports Managed ...
Finally, a small bug in the interactive token retrieval (using the AcquireTokenInteractive method) was fixed. It failed if the user chose ...
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