Interfejs Directory API Google Workspace umożliwia zarządzanie urządzeniami mobilnymi w organizacji. Na tej stronie znajdziesz przykłady wyświetlania listy urządzeń mobilnych, uzyskiwania szczegółowych informacji o konkretnym urządzeniu oraz dodawania i usuwania urządzeń.
W tych przykładach zmienne customerId i resourceId wskazują, gdzie należy podać te identyfikatory. Wartość customerId można uzyskać za pomocą metody Users.get. Parametr resourceId to unikalny identyfikator Google urządzenia, który można znaleźć w odpowiedzi na metodę Pobierz wszystkie urządzenia mobilne.
Odzyskiwanie wszystkich urządzeń mobilnych
Aby pobrać wszystkie urządzenia mobilne na koncie, użyj tego GET
żądania i dodaj autoryzację opisaną w sekcji
Autoryzowanie żądań. Aby ułatwić czytanie, w tym przykładzie użyto znaków łamania wiersza:
Aby pobrać właściwości urządzenia mobilnego, użyj poniższego żądania GET i dodaj autoryzację opisaną w sekcji Autoryzowanie żądań. Aby ułatwić czytanie, w tym przykładzie użyto znaków łamania wiersza:
Aby zatwierdzić urządzenie mobilne, użyj poniższego żądania POST i dołącz autoryzację opisaną w artykule Autoryzowanie żądań.
Aby ułatwić czytanie, przykład zawiera łamania wierszy:
Aby usunąć urządzenie mobilne, użyj poniższego żądania DELETE i dołącz autoryzację opisaną w artykule Autoryzowanie żądań.
Aby ułatwić czytanie, przykład zawiera łamania wierszy:
[null,null,["Ostatnia aktualizacja: 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)."]]