簡體   English   中英

Google Drive API 不顯示共享文件

[英]Google Drive API doesn't show shared files

我需要在 Google 雲端硬盤 API 上與我共享的列表文件,但從昨天到現在我一直在嘗試但沒有成功。 我有這個單一的代碼:

  const auth = new google.auth.JWT({
    email: 'xxxxxx@xxxxxx-322013.iam.gserviceaccount.com',
    key: '-----BEGIN PRIVATE KEY-----\nfkdajlsfçdklasf-\n',
    scopes: [
      'https://www.googleapis.com/auth/documents',
      'https://www.googleapis.com/auth/drive.file',
    ],
  });
  
  // shared file (owned by regular user and shared with the API service account email)
  const template = '1xcy8PjkRVzjZ-E7jY6gJtSyvSXlCbNyqEYrVS-3nQIY';

  const drive = google.drive({
    version: 'v3',
    auth,
  });

  // entire shared folder (owned by regular user and shared with the API service account email)
  const folderId = '1j0y8rttjNe4JecDH065L9GwEKw_a_nmC';

  const filesDrive = await drive.files.list({
    supportsAllDrives: true,
    includeItemsFromAllDrives: true,
    
  });

  console.log(filesDrive);

我嘗試了多種參數組合,但共享文件從未顯示在 filesDrive object 中。

在接下來的步驟中,我想將文件復制到 API 谷歌驅動器並使用文檔替換幾個詞。

非常感謝

我有同樣的問題,我不得不與服務帳戶 email (client_email) 共享文件夾。

  1. Go 到 drive.google.com
  2. 右鍵單擊要查看的文件夾,然后單擊共享。
  3. 將服務帳戶 email 添加到列表中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM