-
Notifications
You must be signed in to change notification settings - Fork 331
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
NullReferenceException on PublicClientApplication.AcquireTokenAsync() #617
Comments
Same problem, I have tested it with emulator and physical device, I have downgrade to version 1.1.4 preview and it works. Guess it is a problem within the constructor of PublicClientApplication class Regards |
Thank you for confirming, @sergioacortes. To be clear though, in my case I can construct the class just fine. I set its RedirectUri property and only when I call AcquireTokenAsync() I get the exception. I have also downgraded to 1.1.4-preview0002 and things are working again. |
We are aware of the issue w/iOS simulator. Recommendation is to continue using 1.1.4-preview for the time being. |
@sergioacortes, version 1.1.4 seems to be working fine for me on my iPhone with iOS 12. I can't use the resulting token to authenticate with my Azure Mobile Services but I believe that's a problem there (it doesn't look like it supports RS256 JWTs?). The resulting user returned by MSAL seems to be all correct, as far as I can tell. |
Can you try the following, using MSALv2.1.0-preview:
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. |
Update: it looks like I had forgotten to add the Entitlements for the debug version of my app, as you had requested. I did and now I can't run. I have a free Apple developer account, so there are things I can't do just yet. Unless you can drop the keychain-access-groups requirement, I'm afraid I can't validate the fix for you. @jennyf19 , unfortunately it didn't seem to work for me. Using 2.1.0-preview, made sure I had keychain-access-groups in my Entitlements list (I already had it in there for other reasons) using my own access group, tried that same code and got the same NullReferenceException.
Again, this was tested on a real device (iPhone 6S with iOS 12). Let me know if I can provide any additional information. |
Thanks @brunokc - do you have this in the csproj file of the iOS app? |
I do. At first it was only under Release|iPhone. Following your instructions, I added it under Debug|iPhone as well. That's when deployment stopped working, probably due to my limited (free) developer account I'm using. |
@brunokc Can you try w/v2.2.0? if you're still having issues, email me (jeferrie@microsoft.com) and we'll go from there. |
Fixed w/MSALv2.2.0 and update to Wiki w/clearer advice for iOS UIParent and fixing of incorrect link to Xamarin-v2 sample. FYI - @brunokc |
I am getting the exact same error using Microsoft.Identity.Client 2.3.1 - same as @brunokc, things are working very well with 1.1.4. Any ideas? |
@tudor06 - Have you tried restarting the mac and VS, and disconnecting/reconnecting the pairing to the mac. Also, you could try uninstalling the app, clearing the cache completely. |
@tudor06, one key difference for me between 1.1.4 and the current releases was the need to specify an UIParent parameter to the call to
See if that helps you. |
@tudor06 there's a discussion on the UIParent if you want to give feedback or suggestions. |
Which Version of MSAL are you using ?
MSAL 2.0.1-preview
Which platform has the issue?
Xamarin iOS
What authentication flow has the issue?
iPhone with iOS 12.
Repro
Expected behavior
AcquireTokenAsync() should complete successfully and start the client authentication flow on the phone. This same code snipped worked just fine with MSAL 1.1.4-preview0002.
Note that AcquireTokenSilentAsync() works as expected, throwing a MsalUiRequiredException because users.Count is zero.
Actual behavior
The call into AcquireTokenAsync(MsalScopes) throws a NullReferenceException.
Additional context/ Logs / Screenshots
Stack trace when the exception is thrown:
[edit: removed 'other issues' -- it was empty.]
The text was updated successfully, but these errors were encountered: