I want to check owner share settings of gsheets by using gsperad as below.
Now I can get the share data by use list_permissions(file_id)
but I need more information about owner share settings by get True of False of Editors can change permissions and share and Viewers and commenters can see the option to download, print, and copy.
Thank you for your support
CodePudding user response:
In order to manage "Viewers and commenters can see the option to download, print, and copy", viewersCanCopyContent
is used.
In order to manage "Editors can change permissions and share", writersCanShare
is used.
From this situation, in order to achieve your goal of I want to check owner share settings of gsheets by using gsperad as below.
, it is required to confirm the values of viewersCanCopyContent
and writersCanShare
of the file.
When this is reflected in a sample script for gspread, how about the following sample script?
Sample script:
import gspread
from googleapiclient.discovery import build
spreadsheet_id = "###" # Please set your Spreadsheet ID.
client = gspread.oauth(###) # Please use your client of gspread.
service = build("drive", "v3", credentials=client.auth)
res = service.files().get(fileId=spreadsheet_id, fields="viewersCanCopyContent,writersCanShare").execute()
print(res)
When this script is run, you can see the value of
{'viewersCanCopyContent': True, 'writersCanShare': True}
. Here, whenviewersCanCopyContent
isTrue
, "Viewers and commenters can see the option to download, print, and copy" is checked. WhenwritersCanShare
isTrue
, "Editors can change permissions and share" is checked.If you want to manage those values, please use "Files: update" method of Drive API.
Note:
In this sample script, it supposes that you have already been able to get and put values to Google Spreadsheet using gspread for python. Please be careful about this.
About
from googleapiclient.discovery import build
, please check google-api-python-client.