Google Workspace Directory API cho phép bạn quản lý thiết bị di động trong tổ chức của mình. Trang này bao gồm các ví dụ về cách liệt kê thiết bị di động, lấy thông tin chi tiết về một thiết bị cụ thể, cũng như thêm hoặc xoá thiết bị.
Trong các ví dụ này, phần giữ chỗ customerId và resourceId được dùng để cho biết vị trí bạn sẽ cung cấp các mã nhận dạng đó. Bạn có thể lấy customerId từ phương thức Users.get. resourceId là giá trị nhận dạng duy nhất của Google cho một thiết bị và có trong phản hồi của phương thức Truy xuất tất cả thiết bị di động.
Truy xuất tất cả thiết bị di động
Để truy xuất tất cả thiết bị di động của một tài khoản, hãy sử dụng yêu cầu GET sau đây và thêm quyền uỷ quyền được mô tả trong phần Uỷ quyền yêu cầu. Để dễ đọc, ví dụ này sử dụng các dòng trả về:
Để truy xuất các thuộc tính của thiết bị di động, hãy sử dụng yêu cầu GET sau đây và thêm quyền uỷ quyền được mô tả trong phần Uỷ quyền yêu cầu. Để dễ đọc, ví dụ này sử dụng các dòng trả về:
Để phê duyệt một thiết bị di động, hãy sử dụng yêu cầu POST sau đây và thêm quyền uỷ quyền được mô tả trong phần Uỷ quyền yêu cầu.
Để dễ đọc, ví dụ này sử dụng các dòng trả về:
Để xoá một thiết bị di động, hãy sử dụng yêu cầu DELETE sau đây và thêm quyền uỷ quyền được mô tả trong phần Uỷ quyền yêu cầu.
Để dễ đọc, ví dụ này sử dụng các dòng trả về:
[null,null,["Cập nhật lần gần đây nhất: 2025-08-29 UTC."],[],[],null,["# Directory API: Mobile Devices\n\n|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| 1. [Retrieve all mobile devices](#get_all_mobile_devices) 2. [Retrieve a mobile device](#get_mobile_device) 3. [Take action on a mobile device](#action_mobile_device) 4. [Remove a mobile device](#remove_mobile_device) |\n\n\nThe Google Workspace Directory API allows you to manage mobile devices within your organization. This page\nincludes examples of how to list your mobile devices, obtain details of a specific device, as well\nas adding or removing a device.\n\n\nThis document assumes you have successfully completed the\n[Prerequisites](/workspace/admin/directory/v1/guides/prerequisites#set_up_mobile).\nAndroid devices need to have the\n[device policy app](http://play.google.com/store/apps/details?id=com.google.android.apps.enterprise.dmagent)\ninstalled. iOS devices must be registered with the\n[Google Mobile Management service](https://support.google.com/a/answer/1734200).\n\n\nIn these examples, the placeholders \u003cvar translate=\"no\"\u003ecustomerId\u003c/var\u003e and \u003cvar translate=\"no\"\u003eresourceId\u003c/var\u003e are used to\nindicate where you would provide those IDs. The \u003cvar translate=\"no\"\u003ecustomerId\u003c/var\u003e can be obtained from the\n[Users.get](/workspace/admin/directory/v1/reference/users/get) method. The\n\u003cvar translate=\"no\"\u003eresourceId\u003c/var\u003e is a unique Google identifier for a device and is found in the response of\nthe [Retrieve all mobile devices](#get_all_mobile_devices) method.\n| **Note:** All of the API operations support delegated administrators and Google authorized resellers. However, in this version of the API, the Chrome and mobile device operations **don't** support remote administrative access for Google authorized resellers.\n\nRetrieve all mobile devices\n---------------------------\n\nTo retrieve all of an account's mobile devices, use the following `GET`\nrequest and include the authorization described in\n[Authorize requests](/workspace/admin/directory/v1/guides/authorizing). For readability,\nthis example uses line returns: \n\n```bash\nGET https://admin.googleapis.com/admin/directory/v1/customer/{my_customer|customerId}\n /devices/mobile?projection=\u003cvar translate=\"no\"\u003e{\u003c/var\u003eBASIC|FULL}&query=query\n &orderBy=orderBy category&sortOrder=\u003cvar translate=\"no\"\u003e{\u003c/var\u003eASCENDING|DESCENDING}\n &pageToken=token for next results page\n &maxResults=max number of results per page\n```\n\n\nFor the request and response properties, see the\n[API Reference](/workspace/admin/directory/v1/reference/mobiledevices/list).\n\n### JSON response\n\n```carbon\n{\n \"kind\": \"directory#mobiledevices\",\n \"mobiledevices\": [\n {\n \"kind\": \"directory#mobiledevice\",\n \"resourceId\": \"\u003cvar translate=\"no\"\u003eresourceId\u003c/var\u003e\",\n \"deviceId\": \"\u003cvar translate=\"no\"\u003edeviceId\u003c/var\u003e\",\n \"name\": [\n \"Sales\"\n ],\n \"email\": [\n \"sales@example.com\"\n ],\n \"model\": \"Nexus 4\",\n \"os\": \"Android 4.2.2\",\n \"type\": \"ANDROID\",\n \"status\": \"APPROVED\",\n \"hardwareId\": \"1234567890\",\n \"firstSync\": \"2013-05-15T17:30:04.325Z\",\n \"lastSync\": \"2013-06-05T17:30:04.325Z\",\n \"userAgent\": \"Google Apps Device Policy 4.14\",\n },\n {\n \"kind\": \"directory#mobiledevice\",\n \"resourceId\": \"\u003cvar translate=\"no\"\u003eresourceId\u003c/var\u003e\",\n \"deviceId\": \"\u003cvar translate=\"no\"\u003edeviceId\u003c/var\u003e\",\n \"name\": [\n \"Liz\"\n ],\n \"email\": [\n \"liz@example.com\"\n ],\n \"model\": \"Galaxy Nexus\",\n \"os\": \"Android 4.2.2\",\n \"type\": \"ANDROID\",\n \"status\": \"APPROVED\",\n \"hardwareId\": \"9123456780\",\n \"firstSync\": \"2013-06-05T17:30:04.325Z\",\n \"lastSync\": \"2013-08-12T17:30:04.325Z\",\n \"userAgent\": \"Google Apps Device Policy 4.14\",\n }\n ],\n \"nextPageToken\": \"next_page_token_value\"\n }\n```\n\nRetrieve a mobile device\n------------------------\n\nTo retrieve a mobile device's properties, use the following `GET` request\nand include the authorization described in\n[Authorize requests](/workspace/admin/directory/v1/guides/authorizing). For readability,\nthis example uses line returns: \n\n```bash\nGET https://admin.googleapis.com/admin/directory/v1/customer/{my_customer|customerId}\n /devices/mobile/resourceId?projection=\u003cvar translate=\"no\"\u003e{\u003c/var\u003eFULL|BASIC}\n```\n\n\nFor the request and response properties, see the\n[API Reference](/workspace/admin/directory/v1/reference/mobiledevices/get).\n\n### JSON request\n\nAn example request for the \u003cvar translate=\"no\"\u003eresourceId\u003c/var\u003e is: \n\n```bash\nGET https://admin.googleapis.com/admin/directory/v1/customer/my_customer/devices/\n mobile/resourceId?projection=FULL\n```\n\n### JSON response\n\n```\n{\n \"kind\": \"directory#mobiledevice\",\n \"resourceId\": \"resourceId\",\n \"deviceId\": \"deviceId\",\n \"name\": [\n \"Sales3\"\n ],\n \"email\": [\n \"sales@example.com\"\n ],\n \"model\": \"Nexus 4\",\n \"os\": \"Android 4.2.2\",\n \"type\": \"ANDROID\",\n \"status\": \"APPROVED\",\n \"hardwareId\": \"1234567890\",\n \"firstSync\": \"2010-05-15T17:30:04.325Z\",\n \"lastSync\": \"2013-06-05T17:30:04.325Z\",\n \"userAgent\": \"Google Apps Device Policy 4.14\",\n }\n```\n\nApprove a mobile device\n-----------------------\n\nTo approve a mobile device, use the following `POST` request and include the\nauthorization described in\n[Authorize requests](/workspace/admin/directory/v1/guides/authorizing).\nFor readability, this example uses line returns: \n\n```bash\nPOST https://admin.googleapis.com/admin/directory/v1/customer/{my_customer|customerId}\n /devices/mobile/resourceId/action\n```\n\n\nFor the request and response properties, see the\n[API Reference](/workspace/admin/directory/v1/reference/mobiledevices/action).\n\n### JSON request\n\nThe following JSON request shows a sample request to approve a device: \n\n```bash\nPOST https://admin.googleapis.com/admin/directory/v1/customer/my_customer/devices\n /mobile/resourceId/action\n```\n\nThe request body is: \n\n```text\n{\n \"action\": \"approve\"\n}\n```\n\nA successful request returns an\n[HTTP 200 status code](http://wikipedia.org/wiki/List_of_HTTP_status_codes).\n\nRemove a mobile device\n----------------------\n\nTo remove a mobile device, use the following `DELETE` request and include\nthe authorization described in\n[Authorize requests](/workspace/admin/directory/v1/guides/authorizing).\nFor readability, this example uses line returns: \n\n```bash\nDELETE https://admin.googleapis.com/admin/directory/v1/customer/{my_customer|customerId}\n /devices/mobile/resourceId\n```\n\n\nFor the request and response properties, see the\n[API Reference](/workspace/admin/directory/v1/reference/mobiledevices/delete).\n\nA successful request returns an\n[HTTP 200 status code](http://wikipedia.org/wiki/List_of_HTTP_status_codes)."]]