androidazureandroid-studioazure-ad-msalmicrosoft-entra-id

Android App and Graph: com.microsoft.identity.client.exception.MsalClientException redirect uri doesn't match


This has me banging my head against the wall, the expected uri I can't find ANYWHERE that is expecting that URI. I have checked in entra and the configs for the app. Here is the full error:

com.microsoft.identity.client.exception.MsalClientException: 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.We expected 'msauth://com.raseq.rascompanionalpha/mmbDKi57oif%2FHi7RBEUI4F%2FSLN4%3D' and we received 'msauth://com.raseq.rascompanionalpha/vBrPeV4t52%2FPzwfZYc9t4Z8QEJg%3D'.

(no i don't care it's all getting regenerated anyway)

So in the app I have this json setup:

{ "client_id" : "", "authorization_user_agent" : "DEFAULT", "redirect_uri" : "msauth://com.raseq.rascompanionalpha/vBrPeV4t52%2FPzwfZYc9t4Z8QEJg%3D", "broker_redirect_uri_registered": true, "account_mode" : "SINGLE", "authorities" : [ { "type": "AAD", "audience": { "type": "AzureADMyOrg", "tenant_id": "mine" } } ] }

Then I have this in the manifest:

        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data
                android:host="com.raseq.rascompanionalpha"
                android:path="/vBrPeV4t52/PzwfZYc9t4Z8QEJg="
                android:scheme="msauth" />
        </intent-filter>
    </activity>

And when I go into azure for the app registration i have this:

enter image description here

I do not understand where it is pulling that expected URI

Where else would that be squirrel away?

I've told it to clean and rebuild the project. I've tried re-signing the app.

But every time the expected one comes back as the exact same thing... Even the great copilot and chatgpt just run in circles, and my google fu just finds people who don't know how to do the registration in the first place.


Solution

  • com.microsoft.identity.client.exception.MsalClientException: 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.We expected 'msauth://com.raseq.rascompanionalpha/mmbDKi57oif%2FHi7RBEUI4F%2FSLN4%3D' and we received 'msauth://com.raseq.rascompanionalpha/vBrPeV4t52%2FPzwfZYc9t4Z8QEJg%3D'.

    Even I got same Error when running an Android app with Azure AD. To resolve the issue, set:

    "broker_redirect_uri_registered": false,
    

    in res/raw/auth_config_single_account.json.

    complete code:

    {  
      "client_id" : "<clientid>",  
      "authorization_user_agent" : "DEFAULT",  
      "redirect_uri" : "msauth://com.azuresamples.msalandroidapp/<hashcode>",  
      "account_mode" : "SINGLE",  
      "broker_redirect_uri_registered": false,  
      "authorities" : [  
        {  
          "type": "AAD",  
          "authority_url": "https://login.microsoftonline.com/ID"  
      }  
      ]  
    }
    

    Output:

    enter image description here