Chrome Management Enrollment Tokens API के लिए कोड सैंपल

एपीआई की सुविधाओं के बारे में खास जानकारी पाने के लिए, Chrome Management Enrollment Tokens API पर जाएं.

इस पेज पर दिखाए गए सभी अनुरोध, इन वैरिएबल का इस्तेमाल करते हैं:

  • $TOKEN - OAuth 2.0 टोकन
  • $CUSTOMER - ग्राहक का आईडी या लिटरल my_customer

रजिस्ट्रेशन टोकन बनाना

ब्राउज़र डिवाइस के लिए नया एनरोलमेंट टोकन बनाने के लिए, एचटीटीपी POST के साथ /enrollmentTokens एंडपॉइंट का इस्तेमाल करें. कस्टम टोकन आईडी असाइन करने के लिए, enrollmentTokenId क्वेरी पैरामीटर तय किया जा सकता है. हालांकि, यह ज़रूरी नहीं है.

अनुरोध

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

जवाब

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

रजिस्ट्रेशन टोकन वापस पाना

एक ही रजिस्ट्रेशन टोकन वापस पाने के लिए, एचटीटीपी GET के साथ /enrollmentTokens/{token_permanent_id} एंडपॉइंट का इस्तेमाल करें.

अनुरोध

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

जवाब

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

रजिस्ट्रेशन टोकन की सूची बनाना

रजिस्ट्रेशन टोकन की सूची बनाने के लिए, एचटीटीपी GET के साथ /enrollmentTokens एंडपॉइंट का इस्तेमाल करें. pageSize (ज़्यादा से ज़्यादा और डिफ़ॉल्ट रूप से 100) और pageToken पैरामीटर का इस्तेमाल करके, पेज नंबर डालने की सुविधा को कंट्रोल किया जा सकता है. नतीजों को सीमित करने के लिए, filter तय करें.

फ़िल्टर क्वेरी के उदाहरण

# 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

अनुरोध

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

जवाब

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

रजिस्ट्रेशन का टोकन रद्द करना

रजिस्ट्रेशन टोकन रद्द करने के लिए, एचटीटीपी POST के साथ /enrollmentTokens/{token_permanent_id}:revoke एंडपॉइंट का इस्तेमाल करें.

अनुरोध

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

जवाब

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