2

I have uploaded a file to a service account and I'd like to transfewr its ownership to a normal Drive account.

Here is what I'm currently doing:

service = build('drive', 'v3', http=http)
service.permissions().create(
    fileId='0B4Z29qk96f_ac3RhcnRlcl9maWxl', 
    transferOwnership=True, 
    body={
      'type': 'user', 
      'role':'owner',
      'emailAddress':'new-user@gmail.com'
     ).execute()

Yet When I try and do this, I always get the following error:

googleapiclient.errors.HttpError: https://www.googleapis.com/drive/v3/files/0B4Z29qk96f_ac3RhcnRlcl9maWxl/permissions?alt=json&transferOwnership=true returned "Bad Request. User message: "You can't yet change the owner of this item. (We're working on it.)""

is there a way to transfer the ownership of a service account Drive file to a normal Google Drive user? If so, how?

API Reference: https://developers.google.com/drive/api/v3/reference/permissions/create.

Note: if I use the 'writer' role it will work, but I need to create a new Owner and transfer the file.

Kamran
  • 3,397
  • 26
  • 40
David542
  • 104,438
  • 178
  • 489
  • 842
  • That's a nice descriptive error message from google lol – Jack Aug 29 '18 at 02:33
  • FWIW, I found I COULD change the ownership of a folder – Peter Alfvin Feb 04 '19 at 04:02
  • @PeterAlfvin can you describe how? I'm assuming you're talking about using the Drive API v3 – otaku Aug 28 '20 at 09:56
  • If you're using G-suite, you can delegate domain wide access to your service account and have it upload the file as the owner [Reference](https://stackoverflow.com/questions/24560314/quota-orphaned-files-and-uploads-using-service-account-with-google-drive-api?rq=1) – otaku Aug 28 '20 at 10:20

0 Answers0