验证 Android 应用链接失败并出现错误 1024

Ari*_*lka 7 java android

我有一个带有 applicationId 的 Android 应用程序com.unibeam.passkey1

https://unibeam.github.io/.well-known/assetlinks.json,我存储了以下文件:

[{
  "relation": ["delegate_permission/common.get_login_creds"],
  "target": {
    "namespace": "web",
    "site": "https://unibeam.github.io"
  }
 },
 {
  "relation": ["delegate_permission/common.get_login_creds"],
  "target": {
    "namespace": "android_app",
    "package_name": "com.unibeam.passkey1",
    "sha256_cert_fingerprints": [
      "55:E2:84:F9:9B:59:82:02:FA:2B:87:B9:90:77:8F:8D:62:3F:32:CC:76:92:47:0C:A8:73:7C:AE:11:8D:B6:0C",
      "0E:67:51:BF:E4:C4:01:7F:CB:7D:4C:1E:02:7E:DF:8D:40:25:9A:5C:20:2A:AB:96:71:15:F1:46:40:09:58:3D"
    ]
  }
 }]
Run Code Online (Sandbox Code Playgroud)

2 个指纹对应应用程序的调试版本和发布版本。

并且检查https://digitalassetlinks.googleapis.com/v1/statements:list?source.web.site=https://unibeam.github.io&relation=delegate_permission/common.get_login_creds返回没有错误。

现在在应用程序的内部manifest.xml,我有以下内容:

<intent-filter android:autoVerify="true">
    <action android:name="android.intent.action.VIEW" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="http" />
    <data android:scheme="https" />
    <data android:host="unibeam.github.io" />
</intent-filter>
Run Code Online (Sandbox Code Playgroud)

问题是运行时adb shell pm get-app-links --user cur com.unibeam.passkey1失败,如下:

  com.unibeam.passkey1:
    ID: 24defbad-89a3-46d4-8446-335dfcdcd0a9
    Signatures: [0E:67:51:BF:E4:C4:01:7F:CB:7D:4C:1E:02:7E:DF:8D:40:25:9A:5C:20:2A:AB:96:71:15:F1:46:40:09:58:3D]
    Domain verification state:
      unibeam.github.io: 1024
    User 0:
      Verification link handling allowed: true
      Selection state:
        Disabled:
          unibeam.github.io
Run Code Online (Sandbox Code Playgroud)

为什么会失败?该应用程序是否需要在 PlayStore 上才能实现这一切?

Gar*_*her 2

您的问题似乎分为两个部分:

让应用程序链接正常工作

为此,您需要 assetlinks.json 文件包含此类条目,如Android 文档中所述。我的代码示例使用这些设置:

[
  {
    "relation": [
      "delegate_permission/common.handle_all_urls"
    ],
    "target": {
      "namespace": "android_app",
      "package_name": "com.authsamples.basicmobileapp",
      "sha256_cert_fingerprints": [
        "62:7D:06:B1:01:C6:2F:04:9A:D4:5D:17:DF:FF:AB:65:13:8E:E0:CC:F6:60:2A:F6:3A:DA:1D:19:0A:F9:DF:15"
      ]
    }
  }
]
Run Code Online (Sandbox Code Playgroud)

这不需要部署到 App Store。您可以通过运行我的示例应用程序来验证这一点,该应用程序在安装时会注册深层链接。我的应用程序使用与您的应用程序类似的清单文件。如果您在模拟器上运行应用程序,则执行以下命令:

adb shell pm get-app-links --user cur
Run Code Online (Sandbox Code Playgroud)

您将看到这样的输出,没有 1024。更多基础设施详细信息请参阅我的这篇博文。

 com.authsamples.basicmobileapp:
    ID: 07f8ee96-dc1c-4df0-a7d7-2e9738902088
    Signatures: [62:7D:06:B1:01:C6:2F:04:9A:D4:5D:17:DF:FF:AB:65:13:8E:E0:CC:F6:60:2A:F6:3A:DA:1D:19:0A:F9:DF:15]
    Domain verification state:
      mobile.authsamples.com: verified
    User 0:
      Verification link handling allowed: true
      Selection state:
        Disabled:
          mobile.authsamples.com
Run Code Online (Sandbox Code Playgroud)

让 WEBAUTHN / 密码本机登录正常运行

这是一项较新的功能,用于使用FIDO 功能,并且需要额外注册,如下所示:

 com.authsamples.basicmobileapp:
    ID: 07f8ee96-dc1c-4df0-a7d7-2e9738902088
    Signatures: [62:7D:06:B1:01:C6:2F:04:9A:D4:5D:17:DF:FF:AB:65:13:8E:E0:CC:F6:60:2A:F6:3A:DA:1D:19:0A:F9:DF:15]
    Domain verification state:
      mobile.authsamples.com: verified
    User 0:
      Verification link handling allowed: true
      Selection state:
        Disabled:
          mobile.authsamples.com
Run Code Online (Sandbox Code Playgroud)

它还需要在应用程序中指定几个步骤asset_statements,如链接中所述。

你的问题

在您的情况下,密钥注册看起来不错,您可以继续为用户实施密钥登录。您的问题令人困惑的是您正在查看应用程序链接注册详细信息。除非您包含该值,否则这些将不起作用handle_all_urls

为了推进您的设置,我将更新为这种形式的 assetlinks.json,如链接中的建议。尽管您的重点可能是密钥登录,但如今任何移动应用程序支持深度链接都是有意义的,即使您最初不使用它。

[
  {
    "relation": [
      "delegate_permission/common.handle_all_urls",
      "delegate_permission/common.get_login_creds"
    ],
    "target": {
      "namespace": "web",
      "site": "https://mobile.authsamples.com"
    }
  }
]
Run Code Online (Sandbox Code Playgroud)