question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Upgrade from MSAL v1.0 to MSAL v2.0+ iOS - Object reference not set to an instance of an object

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:21 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
jennyf19commented, Nov 7, 2018

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.

0reactions
jennyf19commented, Mar 22, 2019

@SravanthiKare missed your reply. This has been fixed. Please try the latest version of MSAL.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ADAL to MSAL migration guide (MSAL iOS/macOS)
Learn the differences between MSAL for iOS/macOS and the Azure AD Authentication Library for Objective-C (ADAL.ObjC) and how to migrate to ...
Read more >
MSAL.Net not working when deployed to Azure App Serivce
I have an API which takes username and password and generate the access_token using MSAL.Net as shown in the code snippet below. It...
Read more >
azure/msal-browser
The MSAL library for JavaScript enables client-side JavaScript applications to authenticate users using Azure AD work and school accounts (AAD), ...
Read more >
msal_flutter | Flutter Package
A Microsoft Authentication Library wrapper for Android and iOS. ... Version 1.0.0 uses the updated MSAL Libraries and moves to Android-X. 1.0.0 IS...
Read more >
@azure/msal-browser - v3.0.0 | Documentation
A vanilla JavaScript sample showing basic usage of the MSAL 2.0 library ( @azure/msal-browser package) with the Microsoft Graph API. npm start --...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found