如何使用Google Drive API获取上次修改用户信息? [英] How to get last modifying user information using google drive API?

查看:46
本文介绍了如何使用Google Drive API获取上次修改用户信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google.Apis.Drive.v2.Data.File 类中,它仅提供最后修改用户的名称.如何获取用户的完整信息(如电子邮件,用户ID等)?

In Google.Apis.Drive.v2.Data.File class it just provides name of the last modifying 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?

在一个组织中,可以有多个具有相同名字和姓氏的人.区分的是用户ID.所以我需要电子邮件ID.

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

这很有可能.

推荐答案

我想出了如何在Java API中进行操作.它远非优雅,但有效.

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();

您还可以使用RevisionList界面来获取所有修改用户.

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

这篇关于如何使用Google Drive API获取上次修改用户信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆