Trying to find the owner of a file by getting the permissions for the file, looping through them, and retrieving the user information (specifically the email address) of the permission with the role of "owner".
PermissionList filePermissions = service.permissions().list(fileID).execute();
for (Permission permission : filePermissions) {
if (permission.getRole().toLowerCase().equals("owner")) {
String fileOwner = permission.getEmailAddress();
}
}
"permission.getEmailAddress()" kept returning null, so I decided to call "toPrettyString()" on every permission and it showed that the permission objects only consistently contained the "id", "kind", "role", and "type", but never "emailAddress".
The Google documentation for the Drive API lists "emailAddress" as one of the properties for permission objects, so I'm confused as to why I can't retrieve it.
I thought it might be related to the user credentials used to get the Drive Service, but even using the credentials of the file owner still yeilds the same results.