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

No, it's not possible to get owner's email at the moment from permission entities.

其他提示

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top