Cloud Identity API v1beta1 BUG - unexpected argument must be provided

56 views
Skip to first unread message

Arti

unread,
Mar 23, 2023, 2:52:07 AM3/23/23
to Google APIs Discovery Service Users
Hi,

I'm trying to use orgUnits.memberships.move method to move a Shared Drive from 1 orgUnit to another.

https://cloud.google.com/identity/docs/reference/rest/v1beta1/orgUnits.memberships/move

The issue is this error:
TypeError: Got an unexpected keyword argument customer

But when I remove the argument customer:
An error occurred: <HttpError 400 when requesting https://cloudidentity.googleapis.com/v1beta1/orgUnits/<orgUnitId>/memberships/shared_drive;<shareDriveId>:move?alt=json returned "Customer id must be provided.". Details: "[{'@type': 'type.googleapis.com/google.rpc.BadRequest', 'fieldViolations': [{'field': 'customer', 'description': 'Customer id must be provided.'}]}]">

Calling method orgUnits.memberships.list is working fine. So I'm really puzzled here. Can anyone take a look?

Thanks!


Python 3.10.10
pip 23.0.1

from __future__ import print_function
import json
import os.path
from google.auth.transport.requests import Request
from google_auth_oauthlib.flow import InstalledAppFlow
from googleapiclient.discovery import build
from googleapiclient.errors import HttpError
import requests
from google.oauth2 import service_account

CREDENTIALS = 'path/to/credentials.json'

def get_service(api_name, api_version, scopes, key_file_location):
    # "Get a service that communicates to a Google API."

    source_credentials = service_account.Credentials.from_service_account_file(
            key_file_location, scopes=scopes)
   
    delegated_credentials = source_credentials.with_subject('na...@example.com')

    # Build the service object.
    service = build(api_name, api_version, credentials=delegated_credentials)

    return service

def main():
    # Authenticate and construct service.
    service = get_service(
            api_name='cloudidentity',
            api_version='v1beta1',
            scopes=scope,
            key_file_location=CREDENTIALS)

    try:
        results = service.orgUnits().memberships().move(name="orgUnits/<orgUnitId>/memberships/shared_drive;<sharedDriveId>",customer="customers/my_customer",destinationOrgUnit="<orgUnitId2>").execute()
        print(results)

    except HttpError as error:
        # TODO(developer) - Handle errors from drive API.
        print(f'An error occurred: {error}')

if __name__ == '__main__':
    main()
Reply all
Reply to author
Forward
0 new messages