Question:I am working on google docs API and google drive API. I am facing one issue while setting the permissions for editors/writers for not able to share the google docs to anyone except for the owner using google docs API.
Can anyone tell me how we can set or change the permissions so that no one can share the google docs to anyone except the owner.I went through this links https://developers.google.com/apps-script/reference/drive/file#isShareableByEditors%28%29 and found one function isShareableByEditors() and https://developers.google.com/drive/api/v3/reference/files in this link I found one more function writersCanShare(). But I am not able to understand How I put this function or set the functions to get my work done.
I want to do it with google API only with PHP language. Any help would be much appreciated.
Answer:I believe your goal is as follows.
- You want to make users not share the Google Document, while the user can edit the Google Document.
- You want to achieve this using googleapis for PHP.
I think that in this case,
writersCanShareis required to be
false. I think that your direction is correct. So, in order to achieve your goal, how about the following sample script?
This script uses Drive API v3.
If an error related to the scope occurs, please include the scope of
https://www.googleapis.com/auth/driveand please authorize the scopes again. But, if you are required to use
https://www.googleapis.com/auth/drive.file, I think that you can use it.
When this script is run, the user who is not the owner of Document cannot share the document while the user can edit the document.
If you have better answer, please add a comment about this, thank you!