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.

Redirect URI doesn't match with the one generated with package name and signature hash.

See original GitHub issue

Why the app always crash and saying that the URI doesn’t match with the one that showing on the AD? I’ve been tried to delete it and make a new one and that not helping either? Is this really a problem with the library either the AD or was that my mistake?

Here the Log:

Process: com.ilhamwahyu.testapp, PID: 10038
    java.lang.IllegalStateException: The redirect URI in the configuration file doesn't match with the one generated with package name and signature hash. Please verify the uri in the config file and your app registration in Azure portal.
        at com.microsoft.identity.client.PublicClientApplicationConfiguration.verifyRedirectUriWithAppSignature(PublicClientApplicationConfiguration.java:453)
        at com.microsoft.identity.client.PublicClientApplicationConfiguration.checkIntentFilterAddedToAppManifestForBrokerFlow(PublicClientApplicationConfiguration.java:471)
        at com.microsoft.identity.client.PublicClientApplication.initializeApplication(PublicClientApplication.java:1024)
        at com.microsoft.identity.client.PublicClientApplication.<init>(PublicClientApplication.java:1006)
        at com.microsoft.identity.client.MultipleAccountPublicClientApplication.<init>(MultipleAccountPublicClientApplication.java:72)
        at com.microsoft.identity.client.PublicClientApplication$2.onTaskCompleted(PublicClientApplication.java:889)
        at com.microsoft.identity.client.PublicClientApplication$2.onTaskCompleted(PublicClientApplication.java:870)
        at com.microsoft.identity.common.internal.controllers.CommandDispatcher$2.run(CommandDispatcher.java:179)
        at android.os.Handler.handleCallback(Handler.java:883)
        at android.os.Handler.dispatchMessage(Handler.java:100)
        at android.os.Looper.loop(Looper.java:214)
        at android.app.ActivityThread.main(ActivityThread.java:7356)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:492)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:930)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:27 (9 by maintainers)

github_iconTop GitHub Comments

10reactions
kadalcjcommented, Feb 5, 2020

This had to be true all along that my Signature Hash was wrong. I follow the steps on Azure Portal but Android Studio gives me an error log. So I come across this. There was a code that I can use to Log the Signature Hash directly from the project.

This is the code.

try {
    info = getPackageManager().getPackageInfo("com.you.name", PackageManager.GET_SIGNATURES);
    for (Signature signature : info.signatures) {
        MessageDigest md;
        md = MessageDigest.getInstance("SHA");
        md.update(signature.toByteArray());
        String something = new String(Base64.encode(md.digest(), 0));
        //String something = new String(Base64.encodeBytes(md.digest()));
        Log.e("hash key", something);
    }
} catch (NameNotFoundException e1) {
    Log.e("name not found", e1.toString());
} catch (NoSuchAlgorithmException e) {
    Log.e("no such an algorithm", e.toString());
} catch (Exception e) {
    Log.e("exception", e.toString());
}

Finally, I can make the right redirect_uri.

Thank you everyone for helping me out.

10reactions
iambmeltcommented, Feb 3, 2020

As an additional tip: For an APK already pushed to a device, there is a handy tool provided in the MSAL repo here which can export the signature hash of an app installed on a device. You can cross reference this value against your configuration in the application and in the Azure Portal.

Here’s a screenshot of our test app: Screenshot_20191218-143550

Read more comments on GitHub >

github_iconTop Results From Across the Web

android - Redirect URI doesn't match with the one generated ...
I can't figure out why this is happening because the config file's content was generated by Azure portal and package name, signature hash,...
Read more >
msalclientexception redirect URI does not match - CodeRanch
On app run, I'm getting this exception MsalClient Exception: The redirect URI does not match with the package name and signature hash.
Read more >
Redirect URL in Android app - Microsoft Q&A
They have to generate a new hash signature computed for their project (even if they are exactly the same) and put in into...
Read more >
Azure Ad package Msal login for Android, iOS and MacOs
The redirect URI for the broker should include your app's package name and ... You can use keytool to generate a Base64-encoded signature...
Read more >
OAuth 2.0 for Client-side Web Applications | Authorization
The redirect_uri passed in the authorization request does not match an authorized redirect URI for the OAuth client ID. Review authorized ...
Read more >

github_iconTop Related Medium Post

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