Due to MonoAndroid9.0, MSAL 3.0.0 Preview Throws System.PlatformNotSupportedException on Xamarin Forms App which target MonoAndroid8.1
See original GitHub issueWhich Version of MSAL are you using ? MSAL 3.0.0-preview
Platform Xamarin Forms, testing with Android on Pixel 3 XL
What authentication flow has the issue?
- Desktop / Mobile
- [ x] 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?
c. This is a new app or experiment
Repro Created a brand new Xamarin Forms app in VS 2019 and install MSAL 3.0.0-Preview in all 3 projects.
Used the fluent api to build
PCA = PublicClientApplicationBuilder.Create(ClientID).Build();
Added the example code from here
Debug the Application.
Expected behavior The authentication flow runs throw the browser and logs the user in.
Actual behavior The following call throws an exception
result = await App.PCA.AcquireTokenInteractive(App.Scopes, null).ExecuteAsync();
Unhandled Exception: System.PlatformNotSupportedException: 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
Issue Analytics
- State:
- Created 5 years ago
- Comments:18 (4 by maintainers)
Top GitHub Comments
@jennyf19 Thank you, that solved it. I had the following line commented out, probably when I was trying to diagnose on my own.
AuthenticationContinuationHelper.SetAuthenticationContinuationEventArgs(requestCode, resultCode, data);
Thank you everyone for your assistance.
The bigger “cons” of leaving MonoAndroid 9 is supportability, because if your app is MonoAndroid8.1, the failure is very cryptic. We should at least provide a better exception.
I am also wary about developers actually wanting to target only 9, because Android API level x (Pie) has not yet gained widespread use.
I’ll look into this.