使用python gspread删除使用client.del_spreadsheet()的电子表格
删除由API服务帐户创建的表的最简单方法是什么?使用GSPREAD API,我能够创建一张工作表,然后作为编辑分享给自己。现在我无法删除,因为我不是所有者。
name = 'mysheet'
gc = gspread.service_account(filename=path_to_credentials)
try:
spreadsheet = gc.open(name)
except gspread.SpreadsheetNotFound:
spreadsheet = gc.create(name)
sharewith = '[email protected]'
spreadsheet.share(sharewith, perm_type='user',
notify=True, role='editor')
我想重复使用服务帐户凭据,但是我很难考虑如何在Google OAuth对象中获得适合与gspread.client()一起使用的凭据。下面类似于我的想法,但我觉得我缺少一些东西。
oa = gspread.oauth(credentials_filename=path_to_credentials)
c = gspread.Client(auth=oa)
c.del_spreadsheet('<spreadsheetId>')
如果有人可以提供见解,我会听。
What is the easiest way to delete a sheet created by an API service account? Using the gspread API, I was able to create a sheet, and then share back to myself as editor. Now I can't delete because I am not the owner.
name = 'mysheet'
gc = gspread.service_account(filename=path_to_credentials)
try:
spreadsheet = gc.open(name)
except gspread.SpreadsheetNotFound:
spreadsheet = gc.create(name)
sharewith = '[email protected]'
spreadsheet.share(sharewith, perm_type='user',
notify=True, role='editor')
I want to reuse the service account credentials, but I am having trouble thinking about how to get the credentials in a Google OAuth object suitable to use with gspread.Client(). Below kind of resembles what I am thinking, but I feel I am missing something.
oa = gspread.oauth(credentials_filename=path_to_credentials)
c = gspread.Client(auth=oa)
c.del_spreadsheet('<spreadsheetId>')
If anyone has insights to offer, I would listen.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论