Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing ownership of google drive file not working - Insufficient permissions for this file

As a google driver user (using my gmail account) I want to transfer ownership of my uploaded files to another user (using their gmail account).

I found this handy tool: https://github.com/davidstrauss/google-drive-recursive-ownership , which makes this call:

service.permissions().update(fileId=drive_item['id'], 
    permissionId=permission_id, body=permission, transferOwnership=True).execute()

I've verified the fileId is correct and the permission_id is correct, along with the permission object that is being passed in as the body.

The code seems good, and it runs great against google drive "native" files (like the google docs and spreadsheets).

But when run against an uploaded PDF, this error occurs:

<HttpError 403 when requesting https://www.googleapis.com/drive/v2/files/0Bxz4bvKt4QekTWlUUHg0XzUydTa/permissions/18055737357773114524
    ?transferOwnership=true&alt=json returned "Insufficient permissions for this file">

Any ideas on why changing ownership of "native" google drive files works fine when using the 'update' method but changing ownership of uploaded files (like PDFs and docx files) doesn't?

like image 680
Colorado Techie Avatar asked Dec 03 '15 22:12

Colorado Techie


People also ask

How to change ownership of a Google Drive file?

Move file – In Google Drive each file can have only one parent folder. By default when changing ownership to a new owner MyDrive a shortcut is created to the original file (this preserves permissions inherited from the folder where the file was placed).

How do I transfer ownership of a folder to a new user?

If you want to transfer ownership of a folder to a new user, the first step is to enter the admin console. Now that you’re in the admin console, first enter the “apps” section. This will let you access all Google Apps, such as Google Docs and Drive. In the admin console, the “apps” section contains all Google Apps, including Google Docs and Drive.

How do I change the owner of a Google workspace file?

If your company is using the Enterprise version of Google Workspace (formerly G Suite), but your contractor isn’t on that same account, there is no direct way to change the owner of their files and you have to use work-arounds that leave the job half done. There are exceptions to this.

How to change the drive file ownership in Gat+?

GAT+ provides the Admins of the domain to perform and take many actions on Drive and Email audit of the domain. One of the options available is the functionality given to the Admin to change the Drive file ownership from one user to another. Navigate to GAT+ > Drive > apply filter and find the file needed.


2 Answers

Changing the ownership of non-Google docs within Google drive can only be done with a Google Apps account, not a regular Google account.

So in order for your script to work, you either need to use a Google Apps account for authentication or there's a few messy workarounds below;

https://productforums.google.com/forum/#!topic/drive/Hz1uUukwKmk https://productforums.google.com/forum/#!topic/drive/VPhNE_HkGLs

like image 59
JayIsTooCommon Avatar answered Oct 16 '22 05:10

JayIsTooCommon


Check whether it is a prevent flag issue . Right click and select shares and try to see if stops you from making any further shares to other people . A file that is shared with somebody with a setting that people with whom it is shared with cannot share it , then you will get insufficient permission errors .

like image 3
Saurabh Chaturvedi Avatar answered Oct 16 '22 07:10

Saurabh Chaturvedi