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 = 'me@myedu.edu'
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.