1

Create Shared Drive

by
Published Jul 27, 2022
Script gdrive Verified

The script

Submitted by hugo989 Typescript (fetch-only)
Verified 6 days ago
1
//native
2

3
type Gdrive = {
4
  token: string;
5
};
6
export async function main(
7
  gdrive_auth: Gdrive,
8
  requestId: string,
9
  drive_name: string,
10
) {
11
  const supportsAllDrives = true;
12
  const CREATE_SHARED_DRIVE_URL = `https://www.googleapis.com/drive/v3/drives/?requestId=${requestId}`;
13

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

27
  return await response.text();
28
}
29

Other submissions
  • Submitted by rossmccrann Deno
    Created 398 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