是否有任何选项或设置可以设置新创建的谷歌电子表格的默认共享,以便服务帐户可以使用 gspread api 读取它们?我不想手动共享每个新电子表格。
谢谢您的回答
答案 0 :(得分:1)
我相信你的目标如下。
Is there any option or setting to set the default sharing of newly created google spreadsheet, in order that a service account can read them using gspread api?
,
在这种情况下,我认为gspread的insert_permission
方法可能可以使用。当它用于电子表格时,它变成如下。 insert_permission
使用 Drive API。
client = gspread.authorize(credentials) # Please use your "credentials" here.
newSpreadsheetTitle = 'sample' # Please set the new Spreadsheet title.
emailAddress = '###' # Please set the email address of the service account.
folderId = '###' # If you want to create new Spreadsheet to the specific folder. Please use this.
spreadsheetId = client.create(newSpreadsheetTitle, folder_id=folderId).id
client.insert_permission(spreadsheetId, emailAddress, 'user', 'writer')