Skip to content

Using MSAL.NET in Unity iOS gives PlatformNotSupportedException #5190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
rafek opened this issue Mar 15, 2025 · 1 comment
Open

Using MSAL.NET in Unity iOS gives PlatformNotSupportedException #5190

rafek opened this issue Mar 15, 2025 · 1 comment

Comments

@rafek
Copy link

rafek commented Mar 15, 2025

I'm on Unity 6 and using Microsoft.Identity.Client at 4.69.1. I'm trying to implement authentication against my already configured Azure AD B2C.

My MSAL client configuration looks like this:

_msalClient =
    PublicClientApplicationBuilder
        .Create(ClientId)
        .WithB2CAuthority(Authority)
        .WithRedirectUri(RedirectUri)
        .WithIosKeychainSecurityGroup("com.my.bundle")
        .Build();

Then I perform token acquisition:

authResult = await
    _msalClient
        .AcquireTokenInteractive(Scopes)
        .WithParentActivityOrWindow(null)
        .ExecuteAsync();

I have URLTypes configured as well. What I keep getting is:

MSAL Error True True MSAL 4.69.1.0 MSAL.CoreCLR Mono Unity IL2CPP (Jan 11 2025 12:24:23) Unix 24.3.0.0 [2025-03-15 09:53:50Z - fb26809c-3bff-4bc1-85e5-cc4af6681276] System.PlatformNotSupportedException: Unix 24.3.0.0

Apparently, Unity reports the system as Unix (24.3.0.0) and it's not supported by MSAL.NET.

Is that an expected behaviour and shall I fall back to call native MSAL for iOS?

Copy link

Here are some similar issues that might help you. Please check if they can solve your problem.


Possible solution (Extracted from existing issue, might be incorrect; please verify carefully)

Solution 1:

For mobile platforms and UWP, MSAL takes care of the token cache for you. On iOS, it stores it in KeyChain. On other runtimes, developers need to define where the cache is stored. Refer to the MSAL documentation for token cache serialization on mobile.

Reference:

Solution 2:

If you are using a .NET Standard assembly, ensure you add a reference to Microsoft.Identity.Client.dll from each platform assembly (e.g., UWP, Android, iOS), not just from the common .NET Standard assembly.

Reference:

Powered by issue-sentinel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant