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

Hãy truy cập 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 hiển thị 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ề một ứ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ề một Ứ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 dùng điểm cuối /apps/web/{app_id}. Xin lưu ý rằng id ứ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"
}

Danh sách 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 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
}

Xử lý các yêu cầu gia hạn

Để có biện pháp xử lý phù 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 của Chrome. Làm theo hướng dẫn thiết lập để truy cập vào API. Sau đó, bạn có thể gửi yêu cầu đến API đó để thực hiện nhiều hành động. Bạn có thể tìm thấy mẫu để tạo 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 đối với một yêu cầu của ứng dụng.

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

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"

Bạn nên để trống phản hồi thành công:

{}

Từ chối yêu cầu gia hạn đối với tất cả người dùng/thiết bị trong 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: "BLOCKED"}
                        },
                updateMask: {paths: "appInstallType"}
                }]
      }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"

Bạn nên để trống phản hồi thành công:

{}

Buộc cài đặt tiện ích cho tất cả người dùng/thiết bị trong 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: "FORCED"}
                        },
                updateMask: {paths: "appInstallType"}
                }]
      }' \
  "https://chromepolicy.googleapis.com/v1/customers/$CUSTOMER/policies/orgunits:batchModify"

Bạn nên để trống phản hồi thành công:

{}