Method assetlinks.check
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
判斷指定來源和目標資產之間是否存在指定的 (方向) 關係。
「關聯」指的是兩項資產之間 (依來源資產聲明擁有權) 的連結意圖。這類關係的例子就是權限或權限的委派。
基礎架構系統最常使用這個指令來檢查動作的先決條件。舉例來說,客戶可能會想知道能否將網址改為傳送到特定行動應用程式。客戶可以檢查網站與行動應用程式的相關資產連結,以判斷是否應執行這項作業。
安全性注意事項:如果你將安全資產指定為來源 (例如 HTTPS 網站或 Android 應用程式),API 就能確保用於產生回應的任何陳述式均以安全的方式由該資產的擁有者建立。反之,如果來源素材資源是不安全的 HTTP 網站 (也就是網址以 http://
而非 https://
開頭),API 就無法安全驗證其陳述式,也無法確保第三方未修改網站的陳述式。詳情請參閱 Digital Asset Links 技術設計規格。
HTTP 要求
GET https://digitalassetlinks.googleapis.com/v1/assetlinks:check
查詢參數
參數名稱 |
類型 |
說明 |
source |
object(Asset ) |
代管陳述式清單的來源。用於將 Check() 呼叫轉送至適當的來源。 |
relation |
string |
關係的查詢字串。 我們會識別與 <kind>/<detail> 格式字串的關係,其中 <kind> 必須是一組預先定義的用途類別之一,而 <detail> 是任意形式的小寫英數字元字串,說明這個陳述式的特定用途。 如需目前支援的關係清單,請參閱 API 說明文件。 查詢要比對資產連結時,查詢和資產連結的關係字串必須完全相符。 範例:關聯 delegate_permission/common.handle_all_urls 的查詢符合關聯 delegate_permission/common.handle_all_urls 的資產連結。 |
target |
object(Asset ) |
陳述的目標資產。 |
回應主體
如果成功,回應主體即會包含具有以下結構的資料:
JSON 表示法 |
{
"linked": boolean,
"maxAge": string,
"debugString": string,
} |
欄位名稱 |
類型 |
說明 |
linked |
boolean |
如果要求中指定的資產與要求中指定的關係連結,則設為 true。必要 |
maxAge |
string |
從放送時間開始,系統會將回應視為有效停止的進一步更新時間。必要 時間長度以秒為單位,最多可有 9 個小數位數,並應以「s 」結尾,例如:"3.5s" 。 |
debugString |
string |
人類可讀的訊息內含有助於使用者瞭解、重現及偵錯結果的資訊。 留言將會以英文撰寫,我們目前不打算提供任何翻譯。 請注意,無法保證這個字串的內容或格式。我們可能會隨時變更任何資訊,恕不另行通知。請勿嘗試透過程式輔助方式剖析這項資料。如果覺得您必須這麼做,因為該 API 不會公開您需要的資訊,請先與我們聯絡。 |
除非另有註明,否則本頁面中的內容是採用創用 CC 姓名標示 4.0 授權,程式碼範例則為阿帕契 2.0 授權。詳情請參閱《Google Developers 網站政策》。Java 是 Oracle 和/或其關聯企業的註冊商標。
上次更新時間:2024-06-26 (世界標準時間)。
[null,null,["上次更新時間:2024-06-26 (世界標準時間)。"],[[["\u003cp\u003eVerifies the existence of a relationship between two digital assets, like websites and apps.\u003c/p\u003e\n"],["\u003cp\u003eUses the \u003ccode\u003eGET\u003c/code\u003e method with query parameters specifying the source, relation, and target assets.\u003c/p\u003e\n"],["\u003cp\u003eReturns a JSON response indicating if the assets are linked and provides additional debugging information.\u003c/p\u003e\n"],["\u003cp\u003ePrimarily used for security checks and ensuring the integrity of relationships between assets.\u003c/p\u003e\n"],["\u003cp\u003eOffers enhanced security when the source asset is secure (HTTPS or Android app).\u003c/p\u003e\n"]]],[],null,["# Method assetlinks.check\n\n- [HTTP request](#body.HTTP_TEMPLATE)\n- [Query parameters](#body.QUERY_PARAMETERS)\n- [Request body](#body.request_body)\n- [Response body](#body.response_body)\n - [JSON representation](#body.CheckResponse.SCHEMA_REPRESENTATION)\n- [Try it!](#try-it)\n\nDetermines whether the specified (directional) relationship exists between the specified source and target assets.\n\nThe relation describes the intent of the link between the two assets as claimed by the source asset. An example for such relationships is the delegation of privileges or permissions.\n\nThis command is most often used by infrastructure systems to check preconditions for an action. For example, a client may want to know if it is OK to send a web URL to a particular mobile app instead. The client can check for the relevant asset link from the website to the mobile app to decide if the operation should be allowed.\n\nA note about security: if you specify a secure asset as the source, such as an HTTPS website or an Android app, the API will ensure that any statements used to generate the response have been made in a secure way by the owner of that asset. Conversely, if the source asset is an insecure HTTP website (that is, the URL starts with `http://` instead of `https://`), the API cannot verify its statements securely, and it is not possible to ensure that the website's statements have not been altered by a third party. For more information, see the [Digital Asset Links technical design specification](https://github.com/google/digitalassetlinks/blob/master/well-known/details.md).\n\n### HTTP request\n\n`GET https://digitalassetlinks.googleapis.com/v1/assetlinks:check`\n\n### Query parameters\n\n| Parameter name | Type | Description |\n|----------------|-------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `source` | `object(`[Asset](/digital-asset-links/reference/rest/v1/Asset)`)` | The source hosting the statement list. This is used to route the `Check()` call to the proper source. |\n| `relation` | `string` | Query string for the relation. We identify relations with strings of the format `\u003ckind\u003e/\u003cdetail\u003e`, where `\u003ckind\u003e` must be one of a set of pre-defined purpose categories, and `\u003cdetail\u003e` is a free-form lowercase alphanumeric string that describes the specific use case of the statement. Refer to [our API documentation](/digital-asset-links/v1/relation-strings) for the current list of supported relations. For a query to match an asset link, both the query's and the asset link's relation strings must match exactly. Example: A query with relation `delegate_permission/common.handle_all_urls` matches an asset link with relation `delegate_permission/common.handle_all_urls`. |\n| `target` | `object(`[Asset](/digital-asset-links/reference/rest/v1/Asset)`)` | The target asset of the statement. |\n\n### Request body\n\nThe request body must be empty.\n\n### Response body\n\nIf successful, the response body contains data with the following structure:\nResponse message for the CheckAssetLinks call.\n\n| JSON representation |\n|-------------------------------------------------------------------------|\n| ``` { \"linked\": boolean, \"maxAge\": string, \"debugString\": string, } ``` |\n\n| Field name | Type | Description |\n|---------------|-----------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `linked` | `boolean` | Set to true if the assets specified in the request are linked by the relation specified in the request. REQUIRED |\n| `maxAge` | `string` | From serving time, how much longer the response should be considered valid barring further updates. REQUIRED A duration in seconds with up to nine fractional digits, terminated by '`s`'. Example: `\"3.5s\"`. |\n| `debugString` | `string` | Human-readable message containing information intended to help end users understand, reproduce and debug the result. The message will be in English and we are currently not planning to offer any translations. Please note that no guarantees are made about the contents or format of this string. Any aspect of it may be subject to change without notice. You should not attempt to programmatically parse this data. If you feel that you need to do this because the information you need is not otherwise exposed by the API, please contact us first. |\n\nTry it!\n-------\n\nUse the [APIs Explorer](https://developers.google.com/apis-explorer/?discovery_url=/digital-asset-links/v1/discoverydocument.json#p/digitalassetlinks/v1/digitalassetlinks.assetlinks.check?relation=delegate_permission%252Fcommon.handle_all_urls&source.web.site=https%253A%252F%252Fexample.digitalassetlinks.org&target.androidApp.certificate.sha256Fingerprint=10%253A39%253A38%253AEE%253A45%253A37%253AE5%253A9E%253A8E%253AE7%253A92%253AF6%253A54%253A50%253A4F%253AB8%253A34%253A6F%253AC6%253AB3%253A46%253AD0%253ABB%253AC4%253A41%253A5F%253AC3%253A39%253AFC%253AFC%253A8E%253AC1&target.androidApp.packageName=org.digitalassetlinks.sampleapp) to call this method on live data and see the response."]]