'Error - Intent filter for: BrowserTabActivity is missing. While using AzureAD MSAL Lilbary
Integrating AzureAD SSO to my android app. I have registered an app on Azure portal & get the auth_config.json
file against the same. Implemented the sample code step-by-step as mentioned in docs. But getting the below error.
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.poras.testapp/com.poras.testapp.MainActivity}: java.lang.IllegalStateException: Intent filter for: BrowserTabActivity is missing. Please refer to the MSAL readme.
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3086)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3229)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1926)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:6981)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1445)
Caused by: java.lang.IllegalStateException: Intent filter for: BrowserTabActivity is missing. Please refer to the MSAL readme.
at com.microsoft.identity.client.PublicClientApplication.checkIntentFilterAddedToAppManifest(PublicClientApplication.java:1263)
Below is my app's AndroidManifest.xml
& auto.config.json
.
<!--Intent filter to capture System Browser calling back to our app after Sign In-->
<activity android:name="com.microsoft.identity.client.BrowserTabActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<!--Add in your scheme/host from registered redirect URI-->
<data android:scheme="msauth"
android:host= "com.poras.xxxxxxx"
android:path= "/vhhxxxxxxxxxxxxxxpqm0=" />
</intent-filter>
</activity>
auto_config.json
{
"client_id" : "dxxxxxxxxxxxxxxxx3",
"authorization_user_agent" : "DEFAULT",
"redirect_uri" : "msauth://com.poras.xxxxxx/vhhxxxxxxxxxxxxxpmq0%3D",
"authorities" : [
{
"type": "AAD",
"audience": {
"type": "AzureADandPersonalMicrosoftAccount",
"tenant_id": "common"
}
}
]
}
I don't know what I am missing.
Solution 1:[1]
This error arises if you don't have the code piece in your manifest.
So ensure that it is exactly as the Microsoft site says with your configuration details put in the correct places. And ensure that you have the exact package name - like in the package attribute inside the manifest tag, as well as the exact signature hash given to you. I suggest you copy the code segment from the Microsoft portal (ie. https://ms.portal.azure.com/?feature.broker=true#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview). Select your app, after clicking App registrations. From the Authentication link in the Manage section, under Android; Click Quickstart for the exact code personalized for your app. (This will have your package name (if entered correctly) and your signature hash in place correctly.)
Again, if needed the code to be inserted in your manifest:
<!--Intent filter to capture System Browser or Authenticator calling back to our app after sign-in-->
<activity
android:name="com.microsoft.identity.client.BrowserTabActivity">
<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:scheme="msauth"
android:host="Enter_the_Package_Name"
android:path="/Enter_the_Signature_Hash" />
</intent-filter>
(code extract from: https://docs.microsoft.com/en-ca/azure/active-directory/develop/tutorial-v2-android)
Solution 2:[2]
For me it was that I omitted to encode app signature for URI. So res/raw/confing.json
should be:
"redirect_uri": "msauth://<yourpackagename>/<base64urlencodedsignature>"
but AndroidManifest.xml
should be:
<activity android:name="com.microsoft.identity.client.BrowserTabActivity"
android:exported="true">
<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="<yourpackagename>"
android:path="/<signature>"
android:scheme="msauth" />
</intent-filter>
</activity>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Yuma Technical Inc. |
Solution 2 | Michał Tajchert |