Chrome Management Profiles API 的程式碼範例

如要瞭解 API 功能的總覽,請參閱 Chrome Management Profiles API

本頁面顯示的所有要求都會使用下列變數:

  • $TOKEN - OAuth 2.0 權杖
  • $CUSTOMER:客戶 ID 或文字常值 my_customer

列出受管理的設定檔

如要列出受管理的設定檔,請使用 /profiles 端點。您可以使用 pageSizepageToken 參數控制結果的分頁。使用 orderBy 指定結果的順序。指定 filter 可進一步縮小搜尋結果範圍。您可以使用 fields 查詢參數指定讀取遮罩,請注意,您可以使用讀取遮罩列出設定檔,並排除 reportingData 欄位,藉此提升效率。

要求

  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"

回應

{
  "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"
}

擷取受管理設定檔

如要擷取受管理的設定檔,請使用 /profiles/{profile_permanent_id} 端點。您可以使用 fields 參數指定讀取遮罩。

要求

  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"

回應

{
  "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"
}

刪除從受管理的設定檔收集的資料

如要刪除從受管理的設定檔收集到的資料,請使用 /profiles/{profile_permanent_id} 端點。

要求

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