如需大致了解 API 功能,请访问 Chrome Management Enrollment Tokens API。
本页面中显示的所有请求均使用以下变量:
$TOKEN- OAuth 2.0 令牌$CUSTOMER- 客户的 ID 或字面值my_customer
创建注册令牌
如需为浏览器设备创建新的注册令牌,请使用 HTTP POST 的 /enrollmentTokens 端点。您可以选择指定 enrollmentTokenId 查询参数来分配自定义 token ID。
请求
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"
}
检索注册令牌
如需检索单个注册令牌,请使用 HTTP 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"
}
列出注册令牌
如需列出注册令牌,请使用 HTTP 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>"
}
撤消注册令牌
如需撤消注册令牌,请使用 HTTP 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"
}