我想从文件中删除权限.
在Drive API v2中,
PermissionId permissionId = service.permissions().getIdForEmail(account).execute();
service.permissions().delete(fileId, permissionId.getId()).execute();
但根据文档,permissions().getIdForEmail(String email)被删除,而alternate则什么也没有.
https://developers.google.com/drive/v3/web/migration
我找不到如何从驱动API v3中的特定emailaddress获取permissionId.
你有什么主意吗?
最佳答案 两年后,但你的问题是我在寻找解决方案时找到的第一个结果.我找到了一个解决方法,我希望这会帮助其他人解决同样的问题.这是我为获取权限ID所做的事情:
this.getPermissionId = function(emailAddress) {
return new Promise((resolve, reject) => {
const input = {
q: '"' + emailAddress + '" in writers or "' + emailAddress + '" in readers',
fields: 'files(permissions)',
pageSize: 1
};
const request = gapi.client.drive.files.list(input);
request.execute(result => {
if(result.error) {
reject(result.error);
} else if(result.files && result.files[0] && result.files[0].permissions && result.files[0].permissions[0]) {
const permissions = result.files[0].permissions;
let permissionId;
permissions.forEach(permission => {
if(permission.emailAddress == emailAddress) {
permissionId = permission.id;
}
});
if(permissionId) {
resolve(permissionId);
}
else {
reject('permissionIdUndefined');
}
}
});
})
};