-
Notifications
You must be signed in to change notification settings - Fork 367
MSAL: PublicClientApplication throws NullReferenceException in constructor on iPhone simulator #611
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
Comments
@devlanfear : had you installed a previous version of the sample application in the past in the simulator? |
I have the same problem |
I was not able to repro using the dev apps inside of MSAL, but repros with other samples and new Xamarin iOS projects. Workaround is to use Msal-1.1.4-preview |
I tried on clean simulator also - same issue @jmprieur |
When i try to install the app on a physical device, i get the following error: the app is not being deployed to the device. Only when i remove the custom Entitlements.plist that the app is being installed but it doesn't work as expected and i am still getting nulls |
I think the issue is in the keychain settings |
In this line: |
Simulator does not use the keychain sharing group, but a device will. The issue is possibly stemming from cc: @jmprieur |
Thanks for opening this issue, I thought it was some kind of issue with Prism. I'm getting the same error
|
Any update on this matter? |
@ali-h2010, @jennyf19 is looking at it. |
@jmprieur , i get Null Reference Exception on both. I have been using keychain on the simulator and it worked fine in all our apps. I tried to add the keychain in the Entitlement and info.plist |
@jmprieur , am i the only one who is facing issues when running on a physical device? |
@jennyf19 did not manage to repro it on a physical device, @ali-h2010 |
Also, @ali-h2010, @jennyf19 mentioned that this seems to be working fine with anything else than the sample: https://github.com/Azure-Samples/active-directory-xamarin-native-v2 |
Same Issue here: Actual behavior Simulator Actual behavior iPhone8/IOS11 |
@jmprieur |
Works on the Physical Device, not on the emulator. |
Thanks for the update @ali-h2010 |
It doesn't work for me even for a new blank project. I also reset the simulator to its initial state just in case. Repro steps: Create a new blank Xamarin.Forms project with the following: App.xaml.cs: I downgraded to MSAL 1.1.4 for now, which appears to be working fine so far. |
@HarlowBurgess @ali-h2010 - Thanks for the update. I need to update my comment as well, as I was able to reproduce with a blank project (as you did), and in other samples. We are not able to repro it in our dev samples. We will keep you posted. Thanks. |
@HarlowBurgess ,@jennyf19 I tested with |
Hi @ali-h2010 - please open a new issue for your problem. MSAL 1.1.4 is used in production env by quite a few people. App.PCA.Users should be populated with users once a token has been acquired. It is essentially a view over the token cache. Please have a look at the sample as it was configured to work with MSAL 1.1.4: https://github.com/Azure-Samples/active-directory-xamarin-native-v2/tree/4d05148599ee999693bcbc0c9b5a5245dda95029 |
The same issue occurs for me when the auth is attempted while the phone screen is locked. Then the library cannot access the keychain and get the teamId, resulting in the error. Maybe adding |
@tipa @ali-h2010 @Rashun001 @armin-o @ZeroPKI @devlanfear Can you try the following:
In the csproj file of the iOS app, you should have this line now included:
Remember to rebuild. Let me know if this works for you. It worked for me on a new iOS app and on our V2 sample. |
@jennyf19 I had the same problem and your solution worked with MSAL 2.1.0-preview on the iPhone Simulator. |
@hig-dev - Excellent...thanks for the quick response. |
@jennyf19 thanks for the update, but I am still a bit confused, as for me it also works with my own, keychain-access-group |
@tipa
Also does this solve the issue I experience when trying to create a PublicClientApplication instance when the screen is locked? Should I open a new issue for this?
|
@devlanfear @ali-h2010 @ZeroPKI Please re-open if you continue to have issues w/this. Thanks for all your help! |
Can I enable keychain while still using automatic provisioning? |
@djarvis you should be able to, yes. |
Not sure how. The "Custom Entitlements" box where I would enter Entitlements.plist is grayed out if I choose "Automatic Provisioning". |
@djarvis In order to use the keychain, you will need to use Manual provisioning and make sure you have the entitlements set correctly. Sorry for the confusion. |
Cool, thanks. I was able to go through the steps here: https://docs.microsoft.com/en-us/xamarin/ios/get-started/installation/device-provisioning/free-provisioning?tabs=windows and get my app working on a device. |
Using https://github.com/Azure-Samples/active-directory-xamarin-native-v2 on iPhone Simulator 11.4
without any changes (also tried with keys from existing apps)
Which Version of MSAL are you using ?
MSAL 2.0.0-preview
Which platform has the issue?
Xamarin.Forms iOS
What authentication flow has the issue?
Mobile
Repro
Expected behavior
Expecting to create new instance of PublicClientApplication
Actual behavior
Constructor throws NullReferenceException
Additional context/ Logs / Screenshots
at Microsoft.Identity.Core.TokenCacheAccessor.GetTeamId () [0x0003f] in <772466974f16475694ca93a5f7a70108>:0
at Microsoft.Identity.Core.TokenCacheAccessor..ctor () [0x0001c] in <772466974f16475694ca93a5f7a70108>:0
at Microsoft.Identity.Core.Telemetry.TelemetryTokenCacheAccessor..ctor () [0x00000] in <772466974f16475694ca93a5f7a70108>:0
at Microsoft.Identity.Client.TokenCache..ctor () [0x00000] in <772466974f16475694ca93a5f7a70108>:0
at Microsoft.Identity.Client.PublicClientApplication..ctor (System.String clientId, System.String authority) [0x00014] in <772466974f16475694ca93a5f7a70108>:0
at Microsoft.Identity.Client.PublicClientApplication..ctor (System.String clientId) [0x00000] in <772466974f16475694ca93a5f7a70108>:0
at UserDetailsClient.App..ctor () [0x00008] in /Users/devlanfear/Desktop/active-directory-xamarin-native-v2-master 3/UserDetailsClient/UserDetailsClient/App.cs:28
at UserDetailsClient.iOS.AppDelegate.FinishedLaunching (UIKit.UIApplication app, Foundation.NSDictionary options) [0x00007] in /Users/devlanfear/Desktop/active-directory-xamarin-native-v2-master 3/UserDetailsClient/UserDetailsClient.iOS/AppDelegate.cs:27
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0002c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/11.12.0.4/src/Xamarin.iOS/UIKit/UIApplication.cs:63
at UserDetailsClient.iOS.Application.Main (System.String[] args) [0x00001] in /Users/devlanfear/Desktop/active-directory-xamarin-native-v2-master 3/UserDetailsClient/UserDetailsClient.iOS/Main.cs:17
The text was updated successfully, but these errors were encountered: