microsoft-authentication-library-for-dotnet: Upgrade from MSAL v1.0 to MSAL v2.0+ iOS - Object reference not set to an instance of an object
name: Bug report about: Create a report to help us improve
Which Version of MSAL are you using ? 2.3.1
Which platform has the issue? Xamarin iOS
What authentication flow has the issue?
- Mobile
- Xamarin.iOS
What is the identity provider ?
- Azure AD B2C
If B2C, what social identity did you use? Email
Repro
I am using a clean Xamarin Forms project file I implement the MSAL library LOWER than version 2.0 I implement the simplest possible interaction with MSAL (see code snippet below): The app works as expected on iOS and Android, launching the login page I update MSAL to any version higher than 2.0 I follow the instructions to add <CodesignEntitlements>Entitlements.plist</CodesignEntitlements> I enable keychain access and specify com.microsoft.adalcache I clean and rebuild the app Now instead of launching the login page, the exception ‘Object reference not set to an instance of an object’ is triggered Upgrading Android does not result in this error I have also attempted to use a later version of MSAL 2.0 in at least two code samples on GitHub and both fail in similar ways even after making the keychain changes
authenticationResult = await ADB2CClient.AcquireTokenAsync(
Constants.Scopes,
App.UiParent);
Expected behavior iOS should still launch the login page.
Actual behavior Object reference not set to an instance of an object’
Additional context/ Logs / Screenshots
Callstack:
AuthTest.Authenticate.LoginPage.Handle_Clicked() in /Users/dbrickley/Projects/AuthTest/AuthTest/Authenticate/LoginPage.xaml.cs:31 System.Runtime.CompilerServices.AsyncVoidMethodBuilder.Start<AuthTest.Authenticate.LoginPage.<Handle_Clicked>d__4>(AuthTest.Authenticate.LoginPage stateMachine) in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.1.0.15/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:84 AuthTest.Authenticate.LoginPage.Handle_Clicked(Xamarin.Forms.Button sender, System.EventArgs e) in Xamarin.Forms.Button.SendClicked() in D:/a/1/s/Xamarin.Forms.Core/Button.cs:133 Xamarin.Forms.Platform.iOS.ButtonRenderer.OnButtonTouchUpInside(UIKit.UIButton sender, System.EventArgs eventArgs) in UIKit.UIControlEventProxy.Activated() in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.1.0.15/src/Xamarin.iOS/UIKit/UIControl.cs:38 UIKit.UIApplication.UIApplicationMain() in UIKit.UIApplication.Main(string[] args, System.IntPtr principal, System.IntPtr delegate) in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.1.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:79 UIKit.UIApplication.Main(string[] args, string principalClassName, string delegateClassName) in /Library/Frameworks/Xamarin.iOS.framework/Versions/12.1.0.15/src/Xamarin.iOS/UIKit/UIApplication.cs:63 AuthTest.iOS.Application.Main(string[] args) in /Users/dbrickley/Projects/AuthTest/AuthTest.iOS/Main.cs:17
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Comments: 21 (5 by maintainers)
Thanks @Journeyman42 - glad it was a quick fix. Here’s our documentation on the UIParent for iOS in case others stumble upon this issue as well.