Stay organized with collections
Save and categorize content based on your preferences.
Searching for security groups
This page explains how to find all of your security groups with the
Cloud Identity Groups API.
REST
To search for all security groups, call
groups.search()
with a query string of labels:cloudidentity.googleapis.com/groups.security.
Python
The following example shows a helper function to search for security groups
using the Python client library:
defsearch_security_groups(service,identity_source_id,pageSize,view):# Set the label to search for all Google groupssearchQuery="&query=parent=='customers/{customer_id}'&&labels:cloudidentity.googleapis.com/groups.security" \
+"&pageSize="+pageSize+"&view="+viewtry:searchGroupsRequest=service.groups().search()searchGroupsRequest.uri+=searchQueryresponse=searchGroupsRequest.execute()print(response)exceptExceptionase:print(e)
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-09-04 UTC."],[[["\u003cp\u003eThis page outlines the process of finding all security groups using the Cloud Identity Groups API.\u003c/p\u003e\n"],["\u003cp\u003eUtilize the \u003ccode\u003egroups.search()\u003c/code\u003e method in the API with the query string \u003ccode\u003elabels:cloudidentity.googleapis.com/groups.security\u003c/code\u003e to search for security groups.\u003c/p\u003e\n"],["\u003cp\u003eWhen using methods that require the \u003ccode\u003ecustomer_id\u003c/code\u003e, ensure it is prepended with "C", like in the example 'C046psxkn'.\u003c/p\u003e\n"],["\u003cp\u003eThe Python example demonstrates a helper function that can be used to search for all security groups, specifying a customer ID and security label.\u003c/p\u003e\n"]]],[],null,["# Searching for security groups\n=============================\n\nThis page explains how to find all of your security groups with the\nCloud Identity Groups API.\n**Note:** When a method requires the `customer_id`, you must prepend a \"C\" to the ID that you can view in the Google Admin console (for example, 'C046psxkn'). \n\n### REST\n\nTo search for all security groups, call\n[`groups.search()`](/identity/docs/reference/rest/v1/groups/search)\nwith a query string of `labels:cloudidentity.googleapis.com/groups.security`.\n\n### Python\n\nThe following example shows a helper function to search for security groups\nusing the Python client library: \n\n def search_security_groups(service, identity_source_id, pageSize, view):\n # Set the label to search for all Google groups\n searchQuery = \"&query=parent=='customers/{customer_id}'&&labels:cloudidentity.googleapis.com/groups.security\" \\\n + \"&pageSize=\" + pageSize + \"&view=\" + view\n try:\n searchGroupsRequest = service.groups().search()\n searchGroupsRequest.uri += searchQuery\n response = searchGroupsRequest.execute()\n print(response)\n except Exception as e:\n print(e)"]]