How to get last modified user information using go

2019-02-27 00:13发布

问题:

In Google.Apis.Drive.v2.Data.File class it just provides name of the last modified user. How to obtain full info of the user (like email, user id etc.).

var service = new DriveService(auth);
Google.Apis.Drive.v2.Data.File file = service.Files.Get("fileid").Fetch();
file.LastModifyingUserName;// = "User Name" //How to get email id of this user?

In an organization there can be more than one person with the same first and last name. It is user id which differentiates. So I need email ID.

E.g Allan Donald => allan1@corp.com
    Allan Donald => allan2@corp.com

This is very much possible.

回答1:

I figured out how to do it in the Java API. It's far from elegant, but it works.

File file; // start with your file
User user = file.getLastModifyingUser();
Permission permission = service.permissions().get(file.getId(), user.getPermissionId()).execute();
String email = permission.getEmailAddress();

You can also use the RevisionList interface to get all the modifying users.