1
Create Shared Drive
One script reply has been approved by the moderators Verified
Created by rossmccrann 717 days ago Viewed 9206 times
0
Submitted by rossmccrann Deno
Verified 717 days ago
1
type Gdrive = {
2
  token: string;
3
};
4
export async function main(
5
  gdrive_auth: Gdrive,
6
  requestId: string,
7
  drive_name: string,
8
) {
9
  const supportsAllDrives = true;
10
  const CREATE_SHARED_DRIVE_URL = `https://www.googleapis.com/drive/v3/drives/?requestId=${requestId}`;
11

12
  const token = gdrive_auth["token"];
13
  const body = {
14
    name: drive_name,
15
  };
16
  const response = await fetch(CREATE_SHARED_DRIVE_URL, {
17
    method: "POST",
18
    body: JSON.stringify(body),
19
    headers: {
20
      Authorization: "Bearer " + token,
21
      "Content-Type": "application/json",
22
    },
23
  });
24

25
  return await response.text();
26
}
27