Google DRIVE API V3 - 使用 nodejs 获取根文件夹 ID

Google DRIVE API V3 - Get a root folder ID with nodejs

我需要获取根文件夹 ID 并过滤以根文件夹为父文件夹的文件夹。使用 Nodejs 和 google 驱动 API v3 。 这是我的代码以及如何更改此代码以获取根文件夹 ID?

const service = google.drive('v3');
   service.files.list({
   auth: client2,
   fields: 'nextPageToken, files(id, name, webContentLink, webViewLink, mimeType, parents)'
     }, (err, res) => {
   if (err) {
     console.error('The API returned an error.');
     throw err;
   }
   const files = res.data.files;
   if (files.length === 0) {
     console.log('No files found.');
   } else {
    
     console.log('Files Found!');
     for (const file of files) {
       console.log(`${file.name} (${file.id})`);

     }

根文件夹的文件夹 ID 为 "root"。 file.list 方法有一个名为 q 的选项参数,用于搜索。

 service.files.list({auth: auth,
    resource: { parents: [ folderId ] },
    q: "'root' in parents",
    fields: '*',
    spaces: 'drive',
    pageToken: pageToken,
  }

这段代码是一种猜测,因为我没有能力在这台机器上测试节点。