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)
# 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()