Mã mẫu cho API thông tin chi tiết về tiện ích / ứng dụng quản lý Chrome

Truy cập/ghé qua API Chi tiết ứng dụng quản lý Chrome để biết thông tin tổng quan về các tính năng API.

Tất cả yêu cầu được trình bày bên dưới đều sử dụng các biến sau:

  • $TOKEN – Mã thông báo OAuth 2
  • $CUSTOMER – Mã khách hàng hoặc giá trị cố định my_customer

Xem thông tin chi tiết về ứng dụng / tiện ích của Chrome

Để xem thông tin chi tiết về một ứng dụng Chrome cụ thể, hãy sử dụng điểm cuối /apps/chrome/{app_id}@{app_version}.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/apps/chrome/abcdefghijklmnopqrstuvwxyzabcdef@1.2.3"

Phản hồi

{
    "name": "customers/<customer>/apps/chrome/abcdefghijklmnopqrstuvwxyzabcdef@1.2.3",
    "displayName": "Sample Google Chrome Extension",
    "description": "A sample Google Chrome extension.",
    "revisionId": "1.2.3",
    "type": "CHROME",
    "iconUri": "https://sample.chrome.extension.google.com/icon.png",
    "detailUri": "https://chrome.google.com/webstore/detail/abcdefghijklmnopqrstuvwxyzabcdef",
    "firstPublishTime": "2010-10-10T10:10:10.123456Z",
    "latestPublishTime": "2020-10-10T10:10:10.123456Z",
    "publisher": "sample.com",
    "homepageUri": "http://sample.chrome.extension.google.com/home",
    "reviewNumber": "10000",
    "reviewRating": 4.5,
    "chromeAppInfo": {
        "supportEnabled": false,
        "minUserCount": 6000000,
        "permissions": [
            {
                "type": "content_security_policy",
                "documentationUri": "https://developer.chrome.com/extensions/contentSecurityPolicy",
                "accessUserData": false
            },
            {
                "type": "contextmenus",
                "documentationUri": "https://developer.chrome.com/extensions/contextMenus",
                "accessUserData": false
            },
        ],
        "siteAccess": [
            {
                "hostMatch": "<all_urls>"
            }
        ],
        "isTheme": false,
        "googleOwned": true,
        "isCwsHosted": true
    }
}

Xem thông tin chi tiết về một ứng dụng Android

Để xem thông tin chi tiết về một ứng dụng Android cụ thể, hãy sử dụng điểm cuối /apps/android/{app_id}@{app_version}.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/apps/android/com.google.android.sample@1.2.3"

Phản hồi

{
    "name": "customers/<customer>/apps/android/com.google.android.sample@1.2.3",
    "displayName": "Sample Android App",
    "description": "A sample Android app.",
    "appId": "com.google.android.sample",
    "revisionId": "1.2.3",
    "type": "ANDROID",
    "iconUri": "https://sample.android.app.google.com/icon.png",
    "detailUri": "https://play.google.com/store/apps/details?id=com.google.android.sample",
    "firstPublishTime": "2010-10-10T10:10:10.123456Z",
    "latestPublishTime": "2020-10-10T10:10:10.123456Z",
    "publisher": "Google LLC",
    "isPaidApp": true,
    "homepageUri": "http://sample.android.app.google.com/home",
    "privacyPolicyUri": "http://sample.android.app.google.com/privacy",
    "reviewNumber": "10000",
    "reviewRating": 4.5,
    "androidAppInfo": {
        "permissions": [
            {
                "type": "android.permission.CAMERA"
            },
        ]
    }
}

Xem thông tin chi tiết về Ứng dụng web tiến bộ

Để xem thông tin chi tiết về một Ứng dụng web Prgoressive cụ thể, hãy sử dụng điểm cuối /apps/web/{app_id}. Lưu ý rằng mã ứng dụng là trang chủ của ứng dụng được mã hoá URL.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/apps/web/http%3A%2F%2Fsample.web.app.google.com%2F"

Phản hồi

{
    "name": "customers/<customer>/apps/web/http%3A%2F%sample.web.app.google.com%2F",
    "displayName": "sample.web.app.google.com",
    "description": "A sample Progressive Web App.",
    "appId": "http://sample.web.app.google.com/",
    "type": "WEB",
    "iconUri": "http://sample.web.app.google.com/icon.png"
}

Liệt kê các tiện ích của Chrome được yêu cầu

Để liệt kê các ứng dụng Chrome được yêu cầu, hãy sử dụng điểm cuối /apps:countChromeAppRequests.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/apps:countChromeAppRequests"

Phản hồi

{
  "requestedApps": [
    {
      "appId": "abcdefghijklmnopqrstuvwxyzabcdef",
      "displayName": "Sample Google Chrome Extension",
      "appDetails": "customers/<customer>/apps/chrome/abcdefghijklmnopqrstuvwxyzabcdef",
      "iconUri": "https://sample.chrome.extension.google.com/icon.png",
      "detailUri": "https://chrome.google.com/webstore/detail/abcdefghijklmnopqrstuvwxyzabcdef",
      "requestCount": "1",
      "latestRequestTime": "2020-10-10T10:10:10.123456Z"
    },
  ],
  "totalSize": 1
}

Thực hiện hành động theo các yêu cầu tiện ích

Để áp dụng biện pháp xử lý thích hợp đối với các yêu cầu liên quan đến ứng dụng từ người dùng cuối, bạn cần sử dụng API Chính sách Chrome. Làm theo hướng dẫn thiết lập để có quyền truy cập vào API. Sau đó, bạn sẽ có thể gửi yêu cầu đến API đó để thực hiện nhiều hành động. Bạn có thể tham khảo mẫu để đưa ra các yêu cầu liên quan đến ứng dụng tại đây. Sau đây là ví dụ về các thao tác phổ biến mà bạn có thể thực hiện theo một yêu cầu của ứng dụng.

Phê duyệt yêu cầu cài đặt thủ công tiện ích cho người dùng/thiết bị thuộc một đơn vị tổ chức

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
        requests: [{
                policyTargetKey: {
                        targetResource: "orgunits/04fatzly4jbjho9",
                        additionalTargetKeys: {"app_id": "chrome:abcdefghijklmnopqrstuvwxyzabcdef"}
                        },
                policyValue: {
                        policySchema: "chrome.users.apps.InstallType",
                        value: {appInstallType: "ALLOWED"}
                        },
                updateMask: {paths: "appInstallType"}
                }]
      }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"

Phản hồi thành công phải trống:

{}

Từ chối yêu cầu sử dụng tiện ích đối với tất cả người dùng/thiết bị thuộc đơn vị tổ chức

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
        requests: [{
                policyTargetKey: {
                        targetResource: "orgunits/04fatzly4jbjho9",
                        additionalTargetKeys: {"app_id": "chrome:abcdefghijklmnopqrstuvwxyzabcdef"}
                        },
                policyValue: {
                        policySchema: "chrome.users.apps.InstallType",
                        value: {appInstallType: "BLOCKED"}
                        },
                updateMask: {paths: "appInstallType"}
                }]
      }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"

Phản hồi thành công phải trống:

{}

Buộc cài đặt tiện ích đối với tất cả người dùng/thiết bị thuộc đơn vị tổ chức

curl -X POST \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $TOKEN" \
  -d '{
        requests: [{
                policyTargetKey: {
                        targetResource: "orgunits/04fatzly4jbjho9",
                        additionalTargetKeys: {"app_id": "chrome:abcdefghijklmnopqrstuvwxyzabcdef"}
                        },
                policyValue: {
                        policySchema: "chrome.users.apps.InstallType",
                        value: {appInstallType: "FORCED"}
                        },
                updateMask: {paths: "appInstallType"}
                }]
      }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"

Phản hồi thành công phải trống:

{}