1
votes

I'm building Azure AD authentication into my Android Application, using MSAL 3.x, however it is throwing errors when attempting to Acquire Token with User Interaction. The documentation for MSAL 3.x suggests that the parent activity or window is needed, however using Unity I'm pretty lost with this. Any help here would be much appreciated.

I have tried a variety of input suggestions from the main documentation, but none of them seems to fit for Unity. The documentation can be found at: https://github.com/AzureAD/microsoft-authentication-library-for-dotnet/wiki/Acquiring-tokens-interactively

authResult = await app.AcquireTokenInteractive(scopes).ExecuteAsync();
authResult = await app.AcquireTokenInteractive(scopes).WithParentActivityOrWindow("need something here").ExecuteAsync();
1

1 Answers

0
votes

Unity uses UnityPlayerActivity or UnityPlayerNativeActivity depending on the version.

The Activity is mandatory in MSAL.NET for Android applications because it is the required context to create the process to acquire the token interactively.

For other situations, you may want to use the main/launcher activity.

For Unity, you may want to look at extending a Unity Activity and creating a hook for your MSAL.NET code.