2

I would like to create a group using the API Cloud Identity and the command groups().create().

To do so, I'v used the example provided by Google:


def create_google_group(service, customer_id, group_id, group_display_name, group_description):
    group_key = {"id": group_id}
    group = {
        "parent": "customers/" + customer_id,
        "description": group_description,
        "displayName": group_display_name,
        "groupKey": group_key,
        # Set the label to specify creation of a Google Group.
        "labels": {
          "cloudidentity.googleapis.com/groups.discussion_forum": ""
        }
    }

    try:
        request = service.groups().create(body=group)
        request.uri += "&initialGroupConfig=WITH_INITIAL_OWNER"
        response = request.execute()
        print(response)
    except Exception as e:
        print(e)

But I got an issue:

<HttpError 400 when requesting https://cloudidentity.googleapis.com/v1/groups?alt=json&initialGroupConfig=WITH_INITIAL_OWNER returned "Invalid resource.parent". Details: "[{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'resource.parent', 'description': 'Invalid resource.parent'}]}]">

For the field customer_id, I tried without any success:

  • data from https://console.developers.google.com/
    • ID clients OAuth 2.0, ID_client: "XXXXXXXXXXXXXXXXX.apps.googleusercontent.com"
    • idem but only: "XXXXXXXXXXXXXXXXX"
    • project identifier: 'yyyy-yyyy-123456'
  • 'me'
  • 'my_email@example.com'
  • 'my_customer'

Thank you in advance for your support to understand what is expected for the field customer_id!

hganger
  • 147
  • 2
  • 12

1 Answers1

2

You can find your customer ID through the Admin console. https://support.google.com/a/answer/10070793?hl=en

There are several other ways to find it as well.

  • User Resource from AdminSDK (customerId field - docs)
  • Organization API for GCP customers (directoryCustomerId field - docs)
Jaisen Mathai
  • 56
  • 1
  • 5
  • thank you for the answer. I've no admin rights! However, even when I want to get the list of the groups I need the customerId. – hganger Nov 20 '20 at 07:52
  • You can get the customer ID without admin rights. Try the organizations.list API. https://cloud.google.com/resource-manager/reference/rest/v1beta1/organizations/list – Jaisen Mathai Nov 21 '20 at 08:15
  • 1
    I tried but I got only empty answers {} with code 200 (OK) – hganger Nov 23 '20 at 09:24