Google Drive API - Adding and Updating Permissions

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-11 03:49:45

问题


I'm working on file sharing on Google Drive in my android app. Here is the scenario... User A shares a file with User B, gives him/her the "writer" role. Later, forgetful User A, again, shares the same file with User B, giving him/her the "reader" role this time. My question is, will this override the first permission? or should the app handle checking of existing file permissions?


回答1:


You can use drive.permissions.update to update role property of a permission, provided that you have fileId and permissionId. The role property will be overridden. But if you notice, there is a additionalRoles[] property that will allow you to add secondary roles to that permission given to a user. Right now, only commenter is allowed. Maybe in the future, more roles will be added in that property.

You can confirm by yourself using Google API Explorer:

  1. First, send drive.files.list request to get fileId of a shared file.
  2. Send drive.permissions.list request with the fileId to get permissionId of a user (it is the id in the reponse).
  3. With fileId and permissionId, now you can use drive.permissions.update to change the role of that user by send the request with role property in the body.


来源:https://stackoverflow.com/questions/12092056/google-drive-api-adding-and-updating-permissions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!