No, it's not possible to get owner's email at the moment from permission entities.
How to get file owners e-mail address Google Drive API
-
11-04-2022 - |
题
So when I retrieve a file via the Google Drive API, I see that there is an attribute called 'owners'. This is an array of owners, with values for kind, displayName, picture, isAuthenticatedUser, and permissionId.
From this information, is it possible to find out what the user's e-mail address/username is?
解决方案 2
其他提示
As of August 2015 the method this works for me:
file_ref.getOwner().getEmail()
It allowed me to identify who is the owner of the file that used to be shared with me, and ask him to take it out of the bin :) Here's entire script (on Win ctrl+Enter shows the console):
function checkTheFile() {
/* paste file id, FILE_ID obtained from its URL */
var fileID = "FILE_ID";
getFileInfo(fileID);
}
function getFileInfo(fileID) {
/* get the file's handle */
var file_ref = DriveApp.getFileById(fileID);
/* output various file info */
Logger.log("Document's title: " + file_ref.getName());
Logger.log("Document's viewers: " + file_ref.getViewers());
Logger.log("Document's owner: " + file_ref.getOwner());
/* email address: */
Logger.log("Document owner's email address: " + file_ref.getOwner().getEmail());
Logger.log("Sharing Permission: " + file_ref.getSharingPermission());
}
You can use Google Docs API.
Unfortunately, it's deprecated... Wish they could add e-mails to Google Drive API.
不隶属于 StackOverflow