Como começar
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Visão geral
O protocolo e a API Digital Asset Links permitem que um app ou site publique
instruções públicas e verificáveis sobre outros apps ou sites. Por exemplo, um site
pode declarar que está associado a um app Android específico ou que
quer compartilhar credenciais de usuário com outro site.
Aqui estão alguns usos possíveis para os Links de recursos digitais:
- O site A declara que os links para o próprio site precisam ser abertos em um app designado em
dispositivos móveis, caso o app esteja instalado.
- O site A declara que pode compartilhar as credenciais de usuário do Chrome com o site
B para que o usuário não precise fazer login no site B se estiver conectado ao site A.
- O app A declara que pode compartilhar configurações do dispositivo, como a localização, com o site B.
Termos-chave
- Principal:é o app ou site que fez a declaração. No Digital Asset Links, o principal é sempre o app ou site que hospeda a lista de instruções.
- Lista de instruções: as instruções estão contidas em uma lista que contém uma ou mais instruções. Uma lista de instruções é um texto não criptografado e acessível ao público, em um local controlado pelo principal e difícil de falsificar ou adulterar.
Pode ser um arquivo independente ou uma seção de outro item maior. Por exemplo, em um site, é um arquivo inteiro. Em um app Android, é uma seção no manifesto do app.
As declarações podem ser visualizadas e verificadas por qualquer pessoa, usando métodos não reservados. Para mais informações, consulte a documentação da lista de instruções.
- Instrução : uma instrução é uma construção JSON bem estruturada que consiste em uma relation (o que a instrução diz para fazer, por exemplo: ativar credenciais de compartilhamento) e um relation (o site ou app a que a relação se aplica). Portanto, cada instrução é como uma sentença, em que a principal diz relação sobre destino.
- Consumidor de declaração:um consumidor de declaração solicita uma lista de instruções de um principal, verifica a presença de uma instrução em relação a um determinado principal e, se houver, pode executar a ação especificada. Para mais informações, consulte a instrução que resume a documentação.
Exemplo de uso rápido
Veja um exemplo muito simplificado de como o site www.example.com poderia
usar Digital Asset Links para especificar que todos os links para URLs nesse site devem
ser abertos em um app designado, e não no navegador:
- O site www.example.com publica uma lista de instruções em
https://www.example.com/.well-known/assetlinks.json. Esse é o nome e o local oficiais de uma lista de instruções em um site. Listas de instruções em qualquer outro local, ou com qualquer outro nome, não são válidas para este site. No
nosso exemplo, a lista de instruções consiste em uma instrução, concedendo ao
app Android a permissão para abrir links no site:
[{
"relation": ["delegate_permission/common.handle_all_urls"],
"target" : { "namespace": "android_app", "package_name": "com.example.app",
"sha256_cert_fingerprints": ["hash_of_app_certificate"] }
}]
Uma lista de instruções oferece suporte a uma matriz de instruções dentro das marcas [ ], mas
o arquivo de exemplo contém apenas uma instrução.
sha256_cert_fingerprints
são as impressões digitais SHA256 do certificado de assinatura do app.
Encontre mais detalhes na documentação dos Links do app Android.
- O app Android listado na instrução acima tem um filtro de intent
que especifica o esquema, o host e o padrão de caminho dos URLs que quer
processar: neste caso, https://www.example.com. O filtro de intent
inclui um atributo especial
android:autoVerify
, novo no
Android M, que indica que o Android precisa verificar a instrução
no site descrito no filtro de intent quando o app for instalado.
- Um usuário instala o app. O Android vê o filtro de intent com o atributo
autoVerify
e verifica a presença da
lista de instruções no site especificado. Se houver, o Android confere
se o arquivo inclui uma declaração que concede o processamento de links para
o app e compara o app com a declaração por hash
de certificado. Se tudo estiver correto, o Android encaminhará todas as intenções de https://www.example.com para o aplicativo example.com.
- O usuário clica em um link para https://www.example.com/puppies no
dispositivo. Esse link pode estar em qualquer lugar: em um navegador, em uma sugestão do Google Search Appliance ou em qualquer outro lugar. O Android encaminha a intent para o app example.com.
- O app example.com recebe a intent e escolhe processá-la,
abrindo a página de filhotes no app. Se, por algum motivo, o
app se recusasse a processar o link ou se o app não estivesse
no dispositivo, o link seria enviado para o próximo gerenciador de intent padrão
correspondente a esse padrão de intent, geralmente o navegador.
Considerações e limitações importantes:
- O protocolo não autentica o principal que faz a
declaração, mas está localizada em um local específico
fortemente associado ao principal e sob o controle dele.
- O protocolo não autentica o destino da instrução, mas fornece um meio para que o autor da chamada autentique o destino (por exemplo, uma instrução identifica destinos de apps para dispositivos móveis por hash de certificado e nome do pacote).
- O protocolo não executa nativamente nenhuma ação de instrução. Em vez disso, ele permite expor instruções, que um aplicativo consumidor precisa validar e decidir se e como agir. O Android M executa essas etapas de forma nativa para você. Por exemplo, se um site delega o processamento de links a um app específico, o Android confere e confere a instrução, confere o app de destino e oferece ao app a opção de processar o link fornecido.
- O protocolo não permite fazer declarações sobre dois terceiros: ou seja, o site A pode fazer uma declaração sobre o site B, mas o site A não pode fazer uma declaração sobre o relacionamento do site B com o site C. No entanto, se o site B confiar no site A, ele poderá verificar
se há uma instrução que concede permissão ao site C e decidir implementá-la.
Próximas etapas
- Verifique se há documentação explícita para seu caso de uso.
- Saiba como criar uma instrução.
Exceto em caso de indicação contrária, o conteúdo desta página é licenciado de acordo com a Licença de atribuição 4.0 do Creative Commons, e as amostras de código são licenciadas de acordo com a Licença Apache 2.0. Para mais detalhes, consulte as políticas do site do Google Developers. Java é uma marca registrada da Oracle e/ou afiliadas.
Última atualização 2024-06-26 UTC.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2024-06-26 UTC."],[[["\u003cp\u003eDigital Asset Links enable apps and websites to make verifiable statements about their relationships with other apps and websites, such as link handling or credential sharing.\u003c/p\u003e\n"],["\u003cp\u003eThese statements are stored in a publicly accessible statement list, typically an "assetlinks.json" file hosted by the app or website making the statement.\u003c/p\u003e\n"],["\u003cp\u003eAndroid M and above automatically uses Digital Asset Links to verify website-to-app associations and direct links to the appropriate app if installed.\u003c/p\u003e\n"],["\u003cp\u003eThe protocol provides a foundation for trust and delegation between digital entities but relies on consumers to validate and act upon the statements.\u003c/p\u003e\n"]]],[],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).\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)*.*\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)\n2. [Learn about creating a statement.](/digital-asset-links/v1/create-statement)"]]