简体   繁体   中英

How to export file from shared drive GCP using service account

I am trying to do export from slides to pdf using service account.

  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. But only with supportsAllDrives=true
  4. The export method responses 404 not found. It doesn't have the supportsAllDrives option

Is there any way to export that file unless using OAuth 2.0 client?

You are right, the method Files: export does not have the option 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 .

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
  • Provide the service account with the necessary delegaiton scopes in the Admin console
  • Specify the impersonated user programmatically in your code

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM