my scenario: I have created a folder inside my Google Drive with the name called folder-root
and shared that folder with my colleagues. My company is using G-Suite for business. Now my other team members have started uploading files and folder inside my folder.
Now I want to take ownership of all files and folder created/uploaded inside my folder to me.
e.g. the hierarchy is
- folder-root --I am the owner
- folder-1 -- Bob is the owner
- file-1 -- Bob is the owner
- folder-2 -- Alice is the owner
- file-2 -- Alice is the owner
- file-3 -- marry is the owner
- folder-1 -- Bob is the owner
Since all the files and folders are created inside my Drive folder so I want to take ownership of all files/folders created inside my folder.
How can do that , I have tried using Google API's v3, and I am getting an error: Bad Request. User message: "Sorry, you do not have permission to share."
this message is coming when I use file id of bob, Alice or marry with my email address
Code is in node.js
function transferOwnerShip(auth) {
const drive = google.drive({version: 'v3', auth});
drive.permissions.create({
fileId: '1_o-rhbFinu1_LZYniFNo1gV0Epv5mYU5',
transferOwnership: 'true',
resource: {
role: 'owner',
type: 'user',
emailAddress: 'my-name@company.com'
}
});
}