简体   繁体   English

Google Drive API 不显示共享文件

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

I need list files shared with me on Google Drive API, but from yesterday to now i'm trying but without success.我需要在 Google 云端硬盘 API 上与我共享的列表文件,但从昨天到现在我一直在尝试但没有成功。 I have this single code:我有这个单一的代码:

  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);

I have tried many combination of parameters, but the shared file never is displayed in the filesDrive object.我尝试了多种参数组合,但共享文件从未显示在 filesDrive object 中。

In the next steps i want to copy the file to the API google drive and replace a few words using docs.在接下来的步骤中,我想将文件复制到 API 谷歌驱动器并使用文档替换几个词。

Thanks a lot非常感谢

I had the same issue, I had to share the folder with the service account email (client_email).我有同样的问题,我不得不与服务帐户 email (client_email) 共享文件夹。

  1. Go to drive.google.com Go 到 drive.google.com
  2. Right click on the folder you want to see it and click share.右键单击要查看的文件夹,然后单击共享。
  3. Add the service account email to the list.将服务帐户 email 添加到列表中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Google 云端硬盘 API:无法删除文件 - Google Drive API : Can't delete file 无法通过驱动器 API 从服务帐户访问“共享”文件? - Cannot access files "shared" from service account via drive API? 使用 gcp 服务帐户和 google 表格在共享驱动器中创建 google 表格文件 api - Creating a google sheet file in a shared drive using a gcp service account and google sheets api AWS Api 网关开发人员门户不显示 API swagger - AWS Api gateway Developer portal doesn't show APis swagger 无法将文件上传到 Google Drive - Unable to upload files to Google Drive 如何通过google drive api在python的google drive中查找当前日期修改的文件和用户名? - How to find modified file and user name on current date in google drive in python by google drive api? Google Drive v3 REST API 返回最多 460 条记录 - Google drive v3 REST API returns max of 460 records Google 云端硬盘 API 配额限制的工作原理 - How the Google Drive API Quota Limit works AWS X-Ray 未在服务 Map 和 API 网关中显示授权方 - AWS X-Ray doesn't show Authorizer in Service Map with API Gateway Firestore 数据未显示 - Firestore data doesn't show up
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM