Chrome Management Enrollment Tokens API için kod örnekleri

API özelliklerine genel bakış için Chrome Management Enrollment Tokens API başlıklı makaleyi inceleyin.

Bu sayfada gösterilen tüm isteklerde aşağıdaki değişkenler kullanılır:

  • $TOKEN - OAuth 2.0 jetonu
  • $CUSTOMER - Müşterinin kimliği veya değişmez değer my_customer

Kayıt jetonu oluşturma

Tarayıcı cihazı için yeni bir kayıt jetonu oluşturmak üzere HTTP POST ile /enrollmentTokens uç noktasını kullanın. İsteğe bağlı olarak, özel bir jeton kimliği atamak için enrollmentTokenId sorgu parametresini belirtebilirsiniz.

İstek

  curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enrollmentTokens" \
  -d '{
    "tokenType": "ENROLLMENT_TOKEN_TYPE_CHROME_BROWSER",
    "orgUnitId": "03ph8a2z3v"
  }'

Yanıt

{
  "name": "customers/<customerId>/enrollmentTokens/<tokenPermanentId>",
  "tokenPermanentId": "<tokenPermanentId>",
  "token": "<tokenValue>",
  "customerId": "<customerId>",
  "orgUnitId": "03ph8a2z3v",
  "state": "ENROLLMENT_TOKEN_STATE_ACTIVE",
  "createTime": "2024-04-23T22:00:00.000Z",
  "creatorId": "user@example.com",
  "tokenType": "ENROLLMENT_TOKEN_TYPE_CHROME_BROWSER"
}

Kayıt jetonu alma

Tek bir kayıt jetonu almak için HTTP GET ile /enrollmentTokens/{token_permanent_id} uç noktasını kullanın.

İstek

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enrollmentTokens/<tokenPermanentId>"

Yanıt

{
  "name": "customers/<customerId>/enrollmentTokens/<tokenPermanentId>",
  "tokenPermanentId": "<tokenPermanentId>",
  "token": "<tokenValue>",
  "customerId": "<customerId>",
  "orgUnitId": "03ph8a2z3v",
  "state": "ENROLLMENT_TOKEN_STATE_ACTIVE",
  "createTime": "2024-04-23T22:00:00.000Z",
  "creatorId": "user@example.com",
  "tokenType": "ENROLLMENT_TOKEN_TYPE_CHROME_BROWSER"
}

Kayıt jetonlarını listeleme

Kayıt jetonlarını listelemek için HTTP GET ile /enrollmentTokens uç noktasını kullanın. Sayfalandırmayı pageSize (maksimum ve varsayılan 100) ve pageToken parametrelerini kullanarak kontrol edebilirsiniz. Sonuçları daraltmak için bir filter belirtin.

Sorguları filtreleme örneği

# Filter by token state
filter=token_state=ACTIVE

# Filter by Organizational Unit path
filter=org_unit_path=/Marketing

# Filter by Organizational Unit path containing spaces
filter=org_unit_path='/Browser Management'

# Filter by Organizational Unit ID
filter=org_unit_id=03ph8a2z3v

# Filter by token state, Organizational Unit path, and device type
filter=token_state=ACTIVE AND org_unit_path=/Marketing AND device_type=CHROME_BROWSER

İstek

  curl -X GET \
  -H "Authorization: Bearer $TOKEN" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enrollmentTokens?pageSize=2&filter=token_state=ACTIVE"

Yanıt

{
  "enrollmentTokens": [
    {
      "name": "customers/<customerId>/enrollmentTokens/<tokenPermanentId1>",
      "tokenPermanentId": "<tokenPermanentId1>",
      "token": "<tokenValue1>",
      "customerId": "<customerId>",
      "orgUnitId": "03ph8a2z3v",
      "state": "ENROLLMENT_TOKEN_STATE_ACTIVE",
      "createTime": "2024-04-23T22:00:00.000Z",
      "creatorId": "user1@example.com",
      "tokenType": "ENROLLMENT_TOKEN_TYPE_CHROME_BROWSER"
    },
    {
      "name": "customers/<customerId>/enrollmentTokens/<tokenPermanentId2>",
      "tokenPermanentId": "<tokenPermanentId2>",
      "token": "<tokenValue2>",
      "customerId": "<customerId>",
      "orgUnitId": "03ph8a2z3v",
      "state": "ENROLLMENT_TOKEN_STATE_ACTIVE",
      "createTime": "2024-04-23T21:30:00.000Z",
      "creatorId": "user2@example.com",
      "tokenType": "ENROLLMENT_TOKEN_TYPE_CHROME_BROWSER"
    }
  ],
  "nextPageToken": "<nextPageToken>"
}

Kayıt jetonunu iptal etme

Bir kayıt jetonunu iptal etmek için HTTP POST ile /enrollmentTokens/{token_permanent_id}:revoke uç noktasını kullanın.

İstek

  curl -X POST \
  -H "Authorization: Bearer $TOKEN" \
  -H "Content-Type: application/json" \
  "https://chromemanagement.googleapis.com/v1/customers/$CUSTOMER/enrollmentTokens/<tokenPermanentId>:revoke" \
  -d '{}'

Yanıt

{
  "name": "customers/<customerId>/enrollmentTokens/<tokenPermanentId>",
  "tokenPermanentId": "<tokenPermanentId>",
  "token": "<tokenValue>",
  "customerId": "<customerId>",
  "orgUnitId": "03ph8a2z3v",
  "state": "ENROLLMENT_TOKEN_STATE_REVOKED",
  "createTime": "2024-04-23T22:00:00.000Z",
  "revokeTime": "2024-04-24T10:15:00.000Z",
  "creatorId": "user@example.com",
  "revokerId": "admin@example.com",
  "tokenType": "ENROLLMENT_TOKEN_TYPE_CHROME_BROWSER"
}