需要获得具有文件权限的用户名

时间:2013-08-20 12:44:06

标签: google-drive-api

使用DriveService.Permission.List()时,您会获得特定文件的权限列表。但是没有任何内容可以唯一标识具有权限的用户帐户。我发现某个地方可以将https://www.googleapis.com/auth/userinfo.email添加到范围列表中以实现此目的,但这只是给了我一个不好的请求,否则它会起作用。

有没有办法让用户名参与?我正在使用服务帐户,因为无法将OAuth2与复制粘贴密码一起使用...

我知道可以使用Documents List API完成此操作,但我不想使用已弃用的API。

1 个答案:

答案 0 :(得分:1)

您需要对https://www.googleapis.com/auth/userinfo.emailhttps://www.googleapis.com/auth/userinfo.email进行授权,并通过在下方提出请求来请求用户个人资料。

GET https://www.googleapis.com/userinfo/v2/me

您可以尝试使用API​​ Explorer:https://developers.google.com/apis-explorer/#p/oauth2/v2/oauth2.userinfo.v2.me.get