Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Any way to get email address from Google Drive API Permissions so I can differentiate 2 users with the same name?

I have read from previous posts [1, 2, 3] that the email address is not displayed for Google Drive Permissions API due to privacy reasons. But I am trying to look for a way to display user permissions where there are 2 different users with the same name.

With the Google Drive sharing UI, you can differentiate two different users with the same name as it also displays their email next to their name (I don't see why this is not possible in the API if the Google Drive UI can get it).

I would prefer not having to rely on the now deprecated DocList API to get the emails from the ACLs.

like image 799
Wilson Avatar asked Jan 03 '13 22:01

Wilson


3 Answers

Unfortunately, using the documents list API is your only option for now to get the email addresses, sorry.

like image 56
Ali Afshar Avatar answered Sep 20 '22 11:09

Ali Afshar


With v3 API yu can specify the fields parameter of your request.

For Get request : request.Fields = "kind,id,type,emailAddress,domain,role,allowFileDiscovery,displayName,photoLink,expirationTime,teamDrivePermissionDetails,deleted"

For List request : request.Fields = "permissions(kind,id,type,emailAddress,domain,role,allowFileDiscovery,displayName,photoLink,expirationTime,teamDrivePermissionDetails,deleted)"

like image 33
Dany Gauthier Avatar answered Sep 19 '22 11:09

Dany Gauthier


About about = service.about().get().execute();
User user = about.getUser();            
System.out.println("user" + user.toString());

You can print out the user information (JSON string). It contains the emailAddress.

You can parse the JSON string for the emailAddress.

like image 39
Tom Lin Avatar answered Sep 21 '22 11:09

Tom Lin