Search code examples
google-apps-scriptgoogle-drive-apigoogle-workspacegoogle-drive-shared-drive

Create a Shared Drive (formerly Team Drive) using Google Apps Script


I am trying to ascertain if it possible to create a new Shared Drive (formerly "Team Drive") using Google Apps Script. I can see plenty examples of creating new folders inside an already-existing team drive, but not creating an entirely new drive.

I am hoping to be able to develop an Apps Script to create new team drives containing a pre-prepared structure of folders and documents, that individual teams can tailor to their own specific needs.


Solution

  • you would have to use a service-account.json (for an account, which has oAuth2 scope https://www.googleapis.com/auth/drive) in order to create a Team Drive through the Drive API. App Script itself does not feature methods to do that, but one can access just any REST API with UrlFetchApp. once wrote a client called CloudDatastore.gs, which should provide a good example of how it works, despite it's another API (and I don't intent to write such a drive client, unless being paid).