Skip to content
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

NullPointerException is thrown if response doesn't contain claims #112

Open
dominic-simplan opened this issue Dec 6, 2023 · 1 comment

Comments

@dominic-simplan
Copy link

dominic-simplan commented Dec 6, 2023

I am getting a NullPointerException error when calling

cordova.plugins.msalPlugin.signInInteractive(resolve, reject, {
                webViewType: "WK_WEB_VIEW",
                prompt: "LOGIN",
            });

for a Azure AAD instance.

The error stack trace:

java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Set java.util.Map.entrySet()' on a null object reference
    at com.wrobins.cordova.plugin.MsalPlugin.processClaims(MsalPlugin.java:563)
    at com.wrobins.cordova.plugin.MsalPlugin.getAccountObject(MsalPlugin.java:554)
    at com.wrobins.cordova.plugin.MsalPlugin.getAuthResult(MsalPlugin.java:542)
    at com.wrobins.cordova.plugin.MsalPlugin.access$1500(MsalPlugin.java:42)
    at com.wrobins.cordova.plugin.MsalPlugin$6$1.onSuccess(MsalPlugin.java:390)
    at com.microsoft.identity.client.PublicClientApplication.postAuthResult(PublicClientApplication.java:2023)
    at com.microsoft.identity.client.SingleAccountPublicClientApplication$3.onTaskCompleted(SingleAccountPublicClientApplication.java:438)
    at com.microsoft.identity.client.SingleAccountPublicClientApplication$3.onTaskCompleted(SingleAccountPublicClientApplication.java:429)
    at com.microsoft.identity.common.java.controllers.CommandDispatcher.commandCallbackOnTaskCompleted(CommandDispatcher.java:562)
    at com.microsoft.identity.common.java.controllers.CommandDispatcher.access$1000(CommandDispatcher.java:86)
    at com.microsoft.identity.common.java.controllers.CommandDispatcher$4.run(CommandDispatcher.java:538)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7918)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:936)

Issue seems to be that the account object doesn't contain any claims and therefore the account.getClaims() returns null instead of a map.

wrobins added a commit that referenced this issue Feb 15, 2024
@dominic-simplan
Copy link
Author

dominic-simplan commented Jun 19, 2024

Hello @wrobins ,
I can see that you fixed the above mentioned line but you also introduced a NonNull annotation here: d909884#diff-e5923747b7842092fa19ae5c75aca5d73f0465b348be327edf209c96e59fa444R580

Now it fails for me with v4.1.1 at the NonNull check. Is there any specific reason for the check?

As far as I can see, the claims are allowed to be null by the msal android library:
https://github.com/AzureAD/microsoft-authentication-library-for-android/blob/f0487a4cbcba7b778185bfe4278704d580b35bd2/msal/src/main/java/com/microsoft/identity/client/Account.java#L137

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant