I want to use Google Drive API to monitor documents within our organization and make sure that nobody is sharing files improperly. In order to do so, I need to be able to see who (or what groups) currently have access to a document in Drive. I thought that the Drive API would be perfect for this, but when I look up a file in the API the info is totally unhelpful.
Each file has a list of permissions, but when I request this list it doesn't say WHO each permission applies to. They say the role (i.e. "reader", "owner", etc) and the type (i.e. "user", "group", etc), but the email_address field is always blank. Even when I'm the owner of the file, or the permission applies to me.
Am I doing something wrong? Is there any way that I can see who the file permissions apply to? Or am I out of luck?
Here is a condensed version of the PHP code that I'm using:
/* getClient creates and returns a Google_Client */
$client = $this->getClient();
$service = new Google_Service_Drive($client);
/* I use the service to look at my files and get a file id */
$optParams = array(
'pageSize' => 20,
'fields' => 'nextPageToken, files(id, name)'
);
$results = $service->files->listFiles($optParams);
foreach ($results->getFiles() as $file) {
$permissions = $service->permissions->listPermissions($file->getId());
var_dump($permissions);
}
P.S. This answer suggests that email addresses are left out for privacy reasons (and also seems to imply that they're never visible?) But it's also talking about V2 of the API and so I don't know if it applies. Also I don't understand why it would hide the emails addresses for privacy reasons when I can clearly see them while using Google Drive in browser.