Search code examples
pythongoogle-admin-sdkgoogle-api-python-client

Google workspace admin SDK, documentation and samples for Data Transfer API (Python)?


I want to transfer one user's files to another user's drive using admin SDK. I read the documentation for data transfer API. To access this API with proper scopes, I need to use the python client for google. I took a look at the available samples but couldn't find anything for the data transfer API specifically.

service = build('admin', 'directory_v1', credentials=creds)
transferService = service.transfers()

AttributeError: 'Resource' object has no attribute 'transfers'

and service = build('transfers', 'v1', credentials=creds) doesn't work either as apparently 'transfers' is not the name of any API. Can someone please help me getting started with the data transfer API?

Thank you


Solution

  • The service directory_v1 indeed doesn't have a transfers() method.

    According to the Guides section from the API mentioned, the correct python service would be datatransfer_v1.

    Modifying the sample code provided:

    service = build('admin', 'datatransfer_v1', credentials=creds)
    transferService = service.transfers()
    

    You may want to refer to Google APIs client for python documentation for this service here.