Mã mẫu dành cho API Hồ sơ quản lý Chrome

Hãy truy cập vào Chrome Management Profiles API để xem tổng quan về các tính năng của API.

Tất cả các yêu cầu xuất hiện trên trang này đều sử dụng các biến sau:

  • $TOKEN – Mã thông báo OAuth 2.0
  • $CUSTOMER – Mã nhận dạng của khách hàng hoặc giá trị cố định my_customer

Liệt kê hồ sơ được quản lý

Để liệt kê các hồ sơ được quản lý, hãy sử dụng điểm cuối /profiles. Bạn có thể kiểm soát việc phân trang kết quả bằng cách sử dụng các tham số pageSizepageToken. Sử dụng orderBy để chỉ định thứ tự của kết quả. Hãy chỉ định một filter để thu hẹp thêm phạm vi kết quả. Bạn có thể chỉ định mặt nạ đọc bằng tham số truy vấn fields, lưu ý rằng bạn có thể cải thiện hiệu suất bằng cách liệt kê các hồ sơ có mặt nạ đọc loại trừ trường reportingData.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/profiles?pageSize=2&orderBy=lastPolicySyncTime&filter=osPlatformType=WINDOWS+AND+affiliationState=PROFILE_ONLY&fields=chromeBrowserProfiles.name,chromeBrowserProfiles.profileId,chromeBrowserProfiles.profilePermanentId,chromeBrowserProfiles.displayName,chromeBrowserProfiles.userEmail,chromeBrowserProfiles.lastActivityTime,chromeBrowserProfiles.osPlatformType,chromeBrowserProfiles.policyCount,chromeBrowserProfiles.reportingData,chromeBrowserProfiles.identityProvider,chromeBrowserProfiles.affiliationState"

Phản hồi

{
  "chromeBrowserProfiles": [
    {
      "name": "customers/<customerId>/profiles/<profilePermanentId1>",
      "profileId": "<profileId1>",
      "profilePermanentId": "<profilePermanentId1>",
      "displayName": "My profile 1",
      "userEmail": "<userEmail1>",
      "lastActivityTime": "2024-04-23T22:05:44.214362Z",
      "osPlatformType": "WINDOWS",
      "policyCount": "2",
      "reportingData": [
        {
          "browserExecutablePath": "<executablePath1>",
          "profilePath": "<profilePath1>",
          "extensionData":[
            {
              "extensionId": "ghbmnnjooekpmoecnnnilnnbdlolhkhi",
              "version": "1.76.1",
              "name": "Google Docs Offline",
              "extensionType": "EXTENSION",
              "homepageUri": "https://chrome.google.com/webstore/detail/ghbmnnjooekpmoecnnnilnnbdlolhkhi",
              "installationType": "NORMAL",
              "isDisabled": true,
              "isWebstoreExtension": true,
              "manifestVersion": 3
            }
          ],
          "policyData":[
            {
              "source": "MACHINE_PLATFORM",
              "name": "AutoSelectCertificateForUrls",
              "value": "\"********\""
            },
            {
              "source": "USER_CLOUD",
              "name": "BrowserThemeColor",
              "value": "\"#00FF00\""
            }
          ]
        }
      ],
      "identityProvider": "GOOGLE_IDENTITY_PROVIDER",
      "affiliationState": "PROFILE_ONLY"
    },
    {
      "name": "customers/<customerId>/profiles/<profilePermanentId2>",
      "profileId": "<profileId2>",
      "profilePermanentId": "<profilePermanentId2>",
      "displayName": "My profile 2",
      "userEmail": "<userEmail2>",
      "lastActivityTime": "2024-04-23T22:05:44.214362Z",
      "osPlatformType": "WINDOWS",
      "policyCount": "1",
      "reportingData": [
        {
          "browserExecutablePath": "<executablePath2>",
          "profilePath": "<profilePath2>",
          "policyData":[
            {
              "source": "USER_CLOUD",
              "name": "CloudProfileReportingEnabled",
              "value": "true"
            }
          ]
        }
      ],
      "identityProvider": "GOOGLE_IDENTITY_PROVIDER",
      "affiliationState": "PROFILE_ONLY"
    }
  ],
  "next_page_token": "<nextPageToken>",
  "total_size": "120"
}

Truy xuất Hồ sơ được quản lý

Để truy xuất một hồ sơ được quản lý, hãy sử dụng điểm cuối /profiles/{profile_permanent_id}. Bạn có thể chỉ định một mặt nạ đọc bằng tham số fields.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/profiles/<profilePermanentId1>?fields=chromeBrowserProfiles.name,chromeBrowserProfiles.profileId,chromeBrowserProfiles.profilePermanentId,chromeBrowserProfiles.displayName,chromeBrowserProfiles.userEmail,chromeBrowserProfiles.lastActivityTime,chromeBrowserProfiles.osPlatformType,chromeBrowserProfiles.policyCount,chromeBrowserProfiles.reportingData,chromeBrowserProfiles.identityProvider,chromeBrowserProfiles.affiliationState"

Phản hồi

{
  "name": "customers/<customerId>/profiles/<profilePermanentId1>",
  "profileId": "<profileId1>",
  "profilePermanentId": "<profilePermanentId1>",
  "displayName": "My profile 1",
  "userEmail": "<userEmail1>",
  "lastActivityTime": "2024-04-23T22:05:44.214362Z",
  "osPlatformType": "WINDOWS",
  "policyCount": "2",
  "reportingData": [
    {
      "browserExecutablePath": "<executablePath1>",
      "profilePath": "<profilePath1>",
      "extensionData":[
        {
          "extensionId": "ghbmnnjooekpmoecnnnilnnbdlolhkhi",
          "version": "1.76.1",
          "name": "Google Docs Offline",
          "extensionType": "EXTENSION",
          "homepageUri": "https://chrome.google.com/webstore/detail/ghbmnnjooekpmoecnnnilnnbdlolhkhi",
          "installationType": "NORMAL",
          "isDisabled": true,
          "isWebstoreExtension": true,
          "manifestVersion": 3
        }
      ],
      "policyData":[
        {
          "source": "MACHINE_PLATFORM",
          "name": "AutoSelectCertificateForUrls",
          "value": "\"********\""
        },
        {
          "source": "USER_CLOUD",
          "name": "BrowserThemeColor",
          "value": "\"#00FF00\""
        }
      ]
    }
  ],
  "identityProvider": "GOOGLE_IDENTITY_PROVIDER",
  "affiliationState": "PROFILE_ONLY"
}

Xoá dữ liệu được thu thập từ hồ sơ được quản lý

Để xoá dữ liệu được thu thập từ một hồ sơ được quản lý, hãy sử dụng điểm cuối /profiles/{profile_permanent_id}.

Yêu cầu

  curl -X DELETE \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/profiles/<profilePermanentId1>"

Đưa ra Lệnh từ xa cho Hồ sơ được quản lý

Để phát lệnh từ xa cho một hồ sơ được quản lý, hãy sử dụng điểm cuối /profiles/{profile_permanent_id}/commands/.

Yêu cầu

  curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  --data '{"command_type":"clearBrowsingData", "payload":{clearCache:true, clearCookies:true}}' \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/profiles/<profilePermanentId1>/commands"

Phản hồi

{
  "name": "customers/<customerId>/profiles/<profilePermanentId1>/commands/<commandId1>",
  "commandType": "clear_browsing_data",
  "payload": {
    "clear_cache": true,
    "clear_cookies": true
  },
  "commandState": "PENDING",
  "issueTime": "2025-04-05T16:43:37.668Z",
  "validDuration": "86400s"
}

Truy xuất Lệnh từ xa được gửi đến Hồ sơ được quản lý

Để truy xuất một lệnh từ xa được gửi đến một hồ sơ được quản lý, hãy sử dụng điểm cuối /profiles/{profile_permanent_id}/commands/{command_id}.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/profiles/<profilePermanentId1>/commands/<commandId1>"

Phản hồi

{
  "name": "customers/<customerId>/profiles/<profilePermanentId1>/commands/<commandId1>",
  "commandType": "clear_browsing_data",
  "payload": {
    "clear_cache": true,
    "clear_cookies": true
  },
  "commandState": "EXECUTED_BY_CLIENT",
  "commandResult": {
    "resultType": "SUCCESS",
    "clientExecutionTime": "2025-04-05T14:01:51.082Z"
  },
  "issueTime": "2025-04-05T14:01:49.914Z",
  "validDuration": "86400s"
}

Liệt kê các lệnh từ xa được gửi đến một hồ sơ được quản lý

Để liệt kê các lệnh từ xa được gửi đến một hồ sơ được quản lý, hãy sử dụng điểm cuối /profiles/{profile_permanent_id}/commands.

Yêu cầu

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/profiles/<profilePermanentId1>/commands?pageSize=2"

Phản hồi

{
  "chromeBrowserProfileCommands": [
    {
      "name": "customers/<customerId>/profiles/<profilePermanentId1>/commands/<commandId1>",
      "commandType": "clear_browsing_data",
      "payload": {
        "clear_cache": true,
        "clear_cookies": true
      },
      "commandState": "EXECUTED_BY_CLIENT",
      "commandResult": {
        "resultType": "SUCCESS",
        "clientExecutionTime": "2025-04-05T14:01:51.082Z"
      },
      "issueTime": "2025-04-05T14:01:49.914Z",
      "validDuration": "86400s"
    },
    {
      "name": "customers/<customerId>/profiles/<profilePermanentId1>/commands/<commandId2>",
      "commandType": "clear_browsing_data",
      "payload": {
        "clear_cache": true,
        "clear_cookies": false
      },
      "commandState": "EXECUTED_BY_CLIENT",
      "commandResult": {
        "resultType": "SUCCESS",
        "clientExecutionTime": "2025-04-05T14:02:59.981Z"
      },
      "issueTime": "2025-04-05T14:02:59.192Z",
      "validDuration": "86400s"
    }
  ],
  "nextPageToken": "<nextPageToken>",
  "totalSize": "10"
}