1

We have created some custom policies in Azure B2C and are using the MSAL libraries to authorize users.

To test this, I'm using the MSAL android app provided in this example:
https://github.com/Azure-Samples/ms-identity-android-java

Signing in works fine, but when requesting a silent token I get the exception below. The msal.js works fine, but the android MSAL library doesn't. We are using the same config.

I've also tried creating a default user flow, and then requesting a silent token works.
Unfortunately I do not know much about the custom policy since it was created by another teammate, but he also doesn't know what to do here. We tried MS support, but no luck so far.

Has someone else came into this issue?

com.microsoft.identity.client.exception.MsalClientException: No cached accounts found for the supplied homeAccountId and clientId
    at com.microsoft.identity.client.internal.controllers.MsalExceptionAdapter.msalExceptionFromBaseException(MsalExceptionAdapter.java:51)
    at com.microsoft.identity.client.PublicClientApplication$18.onError(PublicClientApplication.java:1903)
    at com.microsoft.identity.client.PublicClientApplication$18.onError(PublicClientApplication.java:1894)
    at com.microsoft.identity.common.internal.controllers.CommandDispatcher.commandCallbackOnError(CommandDispatcher.java:442)
    at com.microsoft.identity.common.internal.controllers.CommandDispatcher.access$800(CommandDispatcher.java:83)
    at com.microsoft.identity.common.internal.controllers.CommandDispatcher$3.run(CommandDispatcher.java:424)
    at android.os.Handler.handleCallback(Handler.java:938)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:223)
    at android.app.ActivityThread.main(ActivityThread.java:7656)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
Mat-Tap
  • 725
  • 1
  • 11
  • 27

1 Answers1

0

I also ran into this issue today. I am using Kotlin instead of Java and I do not think it is the exact same problem as given in the question. But it might help someone in the future.

For me the problem was that I had not created my own signature hash. I think Azure can also generate a hash for you but I fixed it by doing the following

I first installed openssl and JDK17. After installing make sure that the bin folders are added to your %PATH%. After that I ran the following command in my terminal.

keytool -exportcert -alias androiddebugkey -keystore %HOMEPATH%\.android\debug.keystore | openssl sha1 -binary | openssl base64

I went to my Azure AD B2C Android app registration under Authentication and added the URI with the generated hash.

Lastly, I changed the hash in my App in the AndroidManifest.xml and the auth_config_b2c.json files.

See the set redirect URI section of the guide for more.

Tim Chermin
  • 304
  • 2
  • 10