开始使用
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
概览
借助 Digital Asset Links 协议和 API,应用或网站可以公开做出有关其他应用或网站的可验证声明。例如,网站可以声明其与特定 Android 应用相关联,也可以声明其希望与其他网站共享用户凭据。
以下是 Digital Asset Links 的一些可能用途:
- 网站 A 声明,如果移动设备上安装了指定应用,则指向该网站的链接应在该应用中打开。
- 网站 A 声明它可以与网站 B 共享其 Chrome 用户凭据,这样用户在登录网站 A 后就不必再登录网站 B。
- 应用 A 声明它可以与网站 B 分享设备设置(例如位置信息)。
关键词
- 正文:正文是指做出声明的应用或网站。在数字资产链接中,正文始终是托管声明列表的应用或网站。
- 语句列表:语句包含在语句列表中,该列表包含一个或多个语句。声明列表是明文,可公开访问,位于正文控制且难以伪造或篡改的位置。
它可以是独立的文件,也可以是其他较大项的一部分。例如,在网站上,它是整个文件;在 Android 应用中,它是应用清单中的一个部分。
任何人都可以使用非专有方法查看和验证对账单。如需了解详情,请参阅语句列表文档。
- 声明: 声明是一种结构严谨的 JSON 构造,由关系(声明要求执行的操作,例如:启用凭据共享)和目标(关系所适用的网站或应用)组成。因此,每个陈述都像一个句子,其中正文对目标说关系。
- 声明消费者:声明消费者从正文请求声明列表,检查是否存在针对给定正文的声明,如果存在,则可以执行指定的操作。如需了解详情,请参阅有关语句使用的文档。
快速使用示例
下面是一个经过大幅简化的示例,展示了网站 www.example.com 如何使用 Digital Asset Links 指定该网站中指向任何网址的链接应在指定应用中打开,而不是在浏览器中打开:
- 网站 www.example.com 在 https://www.example.com/.well-known/assetlinks.json 发布了一个语句列表。这是网站上声明列表的官方名称和位置;任何其他位置或具有任何其他名称的声明列表对该网站均无效。在我们的示例中,语句列表包含一条语句,用于授予其 Android 应用打开其网站上链接的权限:
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target" : { "namespace": "android_app", "package_name": "com.example.app",
"sha256_cert_fingerprints": ["hash_of_app_certificate"] }
}]
语句列表支持 [ ] 标记内的语句数组,但我们的示例文件仅包含一条语句。
sha256_cert_fingerprints
是应用签名证书的 SHA256 指纹。
如需了解详情,请参阅 Android App Links 文档。
- 上述声明中列出的 Android 应用具有一个 intent 过滤器,用于指定其要处理的网址的协议、主机和路径模式:在本例中为 https://www.example.com。该 intent 过滤器包含一个特殊的属性
android:autoVerify
,该属性是 Android M 中的新属性,用于指示 Android 在安装应用时应验证 intent 过滤器中所述网站上的声明。
- 用户安装应用。Android 会看到带有
autoVerify
属性的 intent 过滤器,并检查指定网站上是否存在声明列表;如果存在,Android 会检查该文件是否包含向应用授予链接处理权限的声明,并通过证书哈希值针对该声明验证应用。如果一切正常,Android 随后会将所有 https://www.example.com intent 转发到 example.com 应用。
- 用户在设备上点击指向 https://www.example.com/puppies 的链接。此链接可以位于任何位置:浏览器中、Google 搜索设备建议中或其他任何位置。Android 会将 intent 转发给 example.com 应用。
- example.com 应用接收到 intent 并选择处理它,从而在应用中打开小狗页面。如果该应用因某种原因拒绝处理链接,或者如果设备上没有该应用,则链接会被发送到与该 intent 模式匹配的下一个默认 intent 处理程序(通常是浏览器)。
重要注意事项和限制:
- 该协议不会对做出声明的主账号进行身份验证,但声明位于与主账号密切相关的特定位置,并且受主账号控制。
- 该协议不会对声明目标进行身份验证,但它提供了一种供调用方对目标进行身份验证的方法(例如,声明通过证书哈希和软件包名称来标识移动应用目标)。
- 该协议本身不会执行任何声明操作;相反,它会提供公开声明的功能,使用方应用必须验证这些声明,然后决定是否以及如何根据这些声明采取行动。Android M 会原生执行这些步骤;例如,如果某个网站将链接处理委托给特定应用,Android 会检查并验证该声明,验证目标应用,然后为该应用提供处理给定链接的选项。
- 该协议不支持对两个第三方做出声明:也就是说,网站 A 可以对网站 B 做出声明,但网站 A 无法对网站 B 与网站 C 的关系做出声明。不过,如果网站 B 信任网站 A,它可以检查网站 A 是否有授予网站 C 权限的声明,并决定是否实现该权限。
后续步骤
- 查看是否有针对您的使用情形的明确文档。
- 了解如何创建对账单。
如未另行说明,那么本页面中的内容已根据知识共享署名 4.0 许可获得了许可,并且代码示例已根据 Apache 2.0 许可获得了许可。有关详情,请参阅 Google 开发者网站政策。Java 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-07-27。
[null,null,["最后更新时间 (UTC):2025-07-27。"],[],[],null,["# Getting Started\n\nOverview\n--------\n\nThe Digital Asset Links protocol and API enable an app or website to make public,\nverifiable *statements* about other apps or websites. For example, a website\ncan declare that it is associated with a specific Android app, or it can declare that\nit wants to share user credentials with another website.\n\nHere are some possible uses for Digital Asset Links:\n\n- Website A declares that links to its site should open in a designated app on mobile devices, if the app is installed.\n- Website A declares that it can share its Chrome user credentials with website B so that the user won't have to log in to website B if it is logged into website A.\n- App A declares that it can share device settings, such as location, with website B.\n\n### Key terms\n\n- **Principal:** The principal is the app or website making the statement. In Digital Asset Links, the principal is always the app or website that hosts the statement list.\n- **Statement list** : Statements are contained in a *statement list* that contains one or more statements. A statement list is cleartext and publicly accessible, in a location that is controlled by the principal and difficult to spoof or tamper with. It can be a free-standing file, or a section of another, larger item. For example, on a website, it is an entire file; in an Android app, it is a section in the app manifest. Statements can be viewed and verified by anyone, using non-proprietary methods. [See the statement list documentation for more information](/../digital-asset-links/v1/create-statement.html).\n- **Statement:** A statement is a tightly structured JSON construct that consists of a *relation* (what the statement says to do, for example: Enable sharing credentials) and a *target* (the website or app that the relation applies to). Therefore, each statement is like a sentence, where *principal* says *relation* about *target* . \n- **Statement consumer:** A statement consumer requests a statement list from a principal, checks for the presence of a statement against a given principal, and if it exists, can perform the action specified. [See the statement comsuming documentation for more information](/../digital-asset-links/v1/consuming.html)*.*\n\nQuick usage example\n-------------------\n\nHere's a very simplified example of how the website www.example.com could\nuse Digital Asset Links to specify that any links to URLs in that site should\nopen in a designated app rather than the browser:\n\n1. The website www.example.com publishes a statement list at https://www.example.com/.well-known/assetlinks.json. This is the official name and location for a statement list on a site; statement lists in any other location, or with any other name, are not valid for this site. In our example, the statement list consists of one statement, granting its Android app the permission to open links on its site: \n\n ```\n [{\n \"relation\": [\"delegate_permission/common.handle_all_urls\"],\n \"target\" : { \"namespace\": \"android_app\", \"package_name\": \"com.example.app\",\n \"sha256_cert_fingerprints\": [\"hash_of_app_certificate\"] }\n }]\n ```\n A statement list supports an array of statements within the \\[ \\] marks, but our example file contains only one statement. `sha256_cert_fingerprints` is the SHA256 fingerprints of your app's signing certificate. Find more details in the [Android App Links documentation](https://developer.android.com/training/app-links/verify-android-applinks#web-assoc).\n2. The Android app listed in the statement above has an intent filter that specifies the scheme, host, and path pattern of URLs that it wants to handle: in this case, https://www.example.com. The intent filter includes a special attribute `android:autoVerify`, new to Android M, which indicates that Android should verify the statement on the website described in the intent filter when the app is installed.\n3. A user installs the app. Android sees the intent filter with the `autoVerify` attribute and checks for the presence of the statement list at the specified site; if present, Android checks whether that file includes a statement granting link handling to the app, and verifies the app against the statement by certificate hash. If everything checks out, Android will then forward any https://www.example.com intents to the example.com app.\n4. The user clicks a link to https://www.example.com/puppies on their device. This link could be anywhere: in a browser, in a Google Search Appliance suggestion, or anywhere else. Android forwards the intent to the example.com app.\n5. The example.com app receives the intent and chooses to handle it, opening the puppies page in the app. If for some reason the app had declined to handle the link, or if the app were not on the device, then the link would have been sent to the next default intent handler matching that intent pattern (often the browser).\n\nImportant considerations and limitations:\n-----------------------------------------\n\n- The protocol does not authenticate the principal making the statement, but the statement is located in a specific location strongly associated with the principal, and under control of the principal.\n- The protocol does not authenticate the statement target, but it provides a means for the caller to authenticate the target (for example, a statement identifies mobile app targets by certificate hash and package name).\n- The protocol does not natively perform any statement actions; rather, it enables the ability to expose statements, which a consuming application must validate and then decide whether and how to act upon. Android M natively performs these steps for you; for example, if a website delegates link handling to a specific app, Android checks and verifies the statement, verifies the target app, and then offers the app the option to handle the given link.\n- The protocol does not enable making statements about two third parties: that is, website A can make a statement about website B, but website A cannot make a statement about website B's relationship to website C. However, if website B trusts website A, it can check website A for a statement granting permission to website C, and decide to implement that.\n\nNext steps\n----------\n\n1. [See if there is explicit documentation for your use case.](/../digital-asset-links/v1/using.html)\n2. [Learn about creating a statement.](/../digital-asset-links/v1/create-statement.html)"]]