I created a service account using the following: https://developers.google.com/drive/web/delegation
I downloaded the file it asked me to download as a JSON file if that makes a difference.
Now how do I use that service account to initiate an ownership transfer using app script?
function transferOwnership() {
var fileId = "1YzwfuawY8OiFIw-nbUCagTUhrxmqH2PEyMmYz1NMT9A";
var p = {};
p.role = "owner";
p.type = "user";
p.value = "email@ofnewowner.com";
Drive.Permissions.insert(p,fileId);
}
If the file is in Drive, you should try doing something like this:
function transferOwnership() {
var fileId = "1YzwfuawY8OiFIw-nbUCagTUhrxmqH2PEyMmYz1NMT9A";
var owner = "email@ofnewowner.com";
Drive.getFileById(fileId).setOwner(owner);
}
Hope this helps!
I was able to successfully transfer ownership of a file using a service account, via app script api, by using the library and instructions provided by Spencer Easton.
https://github.com/Spencer-Easton/Apps-Script-Drive-Service-Account-Libarary/blob/master/src/saDrive.gs