microsoft-authentication-library-for-dotnet: [Bug] [Unity] newtonsoft.json causes crashes for MSAL on unity

Which Version of MSAL are you using ? MSAL 4.13.0

Platform net45

What authentication flow has the issue?

  • 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

IPublicClientApplication app = PublicClientApplicationBuilder.Create(ClientId).WithAuthority($"https://login.microsoftonline.com/{Tenant}/v2.0").Build();

Expected behavior The call method returns an IPublicClientApplication that I can use to obtain the token

Actual behavior The system launch this exceptions: ERROR: Exception during construction of EventSource Microsoft.Identity.Client: Unable to load DLL ‘advapi32.dll’: The specified module could not be found.

ERROR: Exception during construction of EventSource System.Collections.Concurrent.ConcurrentCollectionsEventSource: Unable to load DLL ‘advapi32.dll’: The specified module could not be found.

Additional context/ Logs / Screenshots The same method works good in if I build it in mono backend in Android The same method works good if I build it for UWP solutions

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

@bgavrilMS - Looks like Sha256Managed is not part of the Windows Platform FIPS-validated cryptographic algorithms: https://docs.microsoft.com/en-us/dotnet/api/system.security.cryptography.sha256managed.-ctor

If you say that the latest newtonsoft works with unity, then we can update our internal copy to latest as well.

Unfortunately Newtonsoft doesn’t want to make his libraries compatible with Unity. But there is a fork of Newtonsoft that works with unity and it’s updated to the latest version of newtonsoft (12.0). probably you will take only the fix that the fork do to solve the problem. https://github.com/jilleJr/Newtonsoft.Json-for-Unity

Here the core of the fork: This repo is a fork of JamesNK/Newtonsoft.Json containing custom builds for regular standalone, but more importantly AOT (Ahead Of Time) targets such as all IL2CPP builds (WebGL, iOS, Android, Windows, Mac OS X) and portable .NET (UWP, WP8).