错误-用于以下目的的意图过滤器:BrowserTabActivity丢失。使用AzureAD MSAL Lilbary时

问题描述 投票:2回答:1

将AzureAD SSO集成到我的android应用中。我已经在Azure门户上注册了一个应用,并针对该应用获取了auth_config.json文件。如文档中所述逐步实现示例代码。但出现以下错误。

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)

下面是我的应用的AndroidManifest.xmlauto.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"
      }
    }
  ]
}

我不知道我在想什么。

android azure-active-directory azure-ad-graph-api msal
1个回答
0
投票

如果清单中没有代码,则会出现此错误。

因此请确保它与Microsoft网站所说的完全相同,并将您的配置详细信息放在正确的位置。并确保您拥有准确的package name-像清单标签中的package属性中一样,以及提供给您的准确的signature hash。我建议您从Microsoft portal(即https://ms.portal.azure.com/?feature.broker=true#blade/Microsoft_AAD_IAM/ActiveDirectoryMenuBlade/RegisteredAppsPreview)复制代码段。单击应用程序注册后,选择您的应用程序。在Android下的Manage部分的Authentication链接中;单击快速入门以获取针对您的应用个性化的确切代码。 (这将具有您的程序包名称(如果输入正确)和正确的签名哈希。)

同样,如果需要,可在清单中插入代码:

<!--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>

(从https://docs.microsoft.com/en-ca/azure/active-directory/develop/tutorial-v2-android中提取代码)>

© www.soinside.com 2019 - 2024. All rights reserved.