'Get email address of shared users in Google Drive SDK

Because of the simply mind boggling lack of a notify feature in Google drive that notifies people of new files being added to their shared folders, i'm forced to write one. My first version of this system was written using Google App Script. I had to kill that version because the load my client has goes way above and beyond the quota limits for app script and the system shuts down at about 9:30 in the morning.

So I rewrote the app in GAE/GWT and got pretty far along, not I think I have hit another problem. I can't find a way to get the list of shared users on a folder/file. The way the system works, he creates a file. That file is put in a folder, and he launches this app and hits the button. This app then scans the folders and if it finds a new file, it goes into the files permissions, gets the list of email addresses the file is shared with, and sends them an email saying there is a new file. But, the Drive SDK returns everything about the people that a file is shared with, except their email addresses. Is there some switch that I am not finding in the documents yet that would give me these email addresses?

I would really hate to have to rewrite this thing yet again.



Solution 1:[1]

There is some discussion about this, the email address is hidden for privacy. You can get the Id of the user that has access to the file, but not the email address.

email ids related to shared google drive file Google drive api change ownership of files? value attribute for Permissions Resource not populated in responses

Solution 2:[2]

If you have access to the user's permissionId and the fileId, which it sounds like you do, you can get their email address for the file using the Permissions API's get() method (JavaScript version):

var fileId = 'Some Drive fileId';

gapi.client.drive.about.get().execute(function (data) {
    gapi.client.drive.permissions.get({
        'fileId': fileId,
        'permissionId': data.permissionId
    }).execute(function (perms) {
        console.log(perms.emailAddress);
    });
});

See also:

Permissions Resource

About Resource

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Community
Solution 2 Stephen Kaiser