简体   繁体   English

如何使用服务帐户从共享驱动器 GCP 导出文件

[英]How to export file from shared drive GCP using service account

I am trying to do export from slides to pdf using service account.我正在尝试使用服务帐户从幻灯片导出到 pdf。

  1. I have already shared the folder and the file to that service account我已将文件夹和文件共享到该服务帐户
  2. That service account has the drive permissions该服务帐户具有驱动器权限
  3. When I am trying to get that file with get method it responses ok.当我尝试使用get 方法获取该文件时,它的响应正常。 But only with supportsAllDrives=true但只有 supportAllDrives=true
  4. The export method responses 404 not found. 导出方法响应 404 未找到。 It doesn't have the supportsAllDrives option它没有 supportsAllDrives 选项

Is there any way to export that file unless using OAuth 2.0 client?除非使用 OAuth 2.0 客户端,否则有什么方法可以导出该文件?

You are right, the method Files: export does not have the option supportsAllDrives=true你是对的,方法Files: export没有选项supportsAllDrives=true

Usually this option is not necessary as long as the file is explicitly shared with the service account.只要文件明确与服务帐户共享,通常不需要此选项。 However, if you are running into any issues you can do is to use impersonation .但是,如果您遇到任何问题,您可以使用impersonation

This means that the service acocunt can autenticate as you (or any other domain-user) and perform requests on behalf of this user.这意味着服务帐户可以作为您(或任何其他域用户)进行身份验证并代表该用户执行请求。

This will allow the service account to access files on your Drive as if it were the owner of those files.这将允许服务帐户访问您云端硬盘上的文件,就好像它是这些文件的所有者一样。

To set up a service account - follow the steps specified in the documentation.要设置服务帐户 - 请按照文档中指定的步骤操作。

Most important:最重要的:

  • Enable domain-wide delegation for the specific service account in the GCP console在 GCP 控制台中为特定服务帐号启用全域委派
  • Provide the service account with the necessary delegaiton scopes in the Admin console在管理控制台中为服务帐号提供必要的委托范围
  • Specify the impersonated user programmatically in your code在代码中以编程方式指定模拟用户

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

相关问题 使用服务帐户导出 GCP 数据流 SQL - GCP dataflow SQL export using service account 如何使用服务帐户文件向GCP API进行身份验证 - How to authenticate to GCP API with service account file 如何使用 Terraform 将自定义 GCP 角色附加到 GCP 服务帐户 - How to Attach Custom GCP Role to a GCP Service Account Using Terraform 无法通过驱动器 API 从服务帐户访问“共享”文件? - Cannot access files "shared" from service account via drive API? 如何使用 Google Drive API 通过服务帐户访问域中的共享文件? - How to get access to shared files in a domain with a service account using the Google Drive API? 如何使用服务帐户从 API 创建 Google 共享驱动器? - How to create Google shared drives from API, using a Service Account? 通过使用 GCP 计算服务器上的 GCE 元数据服务器的服务帐户使用驱动器 API - Use Drive API through a service account using GCE Metadata server at GCP Compute server 如何直接从 Go 中的 GCP 服务帐户 JSON 密钥文件创建 kube.netes.Clientset? - How can I create a kubernetes.Clientset directly from a GCP service account JSON key file in Go? 如何使用python API从GCP服务帐户以编程方式生成kubernetes配置 - How to programmatically generate kubernetes config from GCP service account using python API GCP:使用 Terraform 从服务帐户中删除 IAM 策略 - GCP: Remove IAM policy from Service Account using Terraform
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM