I'm getting an error when trying to update the value of a spreadsheet via an external editor. I'm using the python library 'gspread'; I have read access to the document but when I try to update a cell I get an API error.
Here is the code (security details obscured). I've looked at other permission error solutions on stackoverflow, but they don't apply to the scenario where an app can read data but not write it.
import gspread
from oauth2client.service_account import ServiceAccountCredentials
scope = [""
, "https://www.googleapis.com/auth/script.external_request"
, "https://www.googleapis.com/auth/spreadsheets"
, "https://www.googleapis.com/auth/script.container.ui"
, 'https://spreadsheets.google.com/feeds'
, "https://mail.google.com/"
, " https://www.googleapis.com/auth/drive"]
credentials = ServiceAccountCredentials.from_json_keyfile_name('project-id-[hiddenID].json', scope)
gc = gspread.authorize(credentials)
sht2 = gc.open_by_url('https://docs.google.com/spreadsheets/d/[hiddenID]')
worksheet = sht2.get_worksheet(0)
val = worksheet.acell('B1').value
print(val)
worksheet.update_acell('B6', 'Bingo!')
It's the last line that calls the error
APIError: {
"error": {
"code": 403,
"message": "The caller does not have permission",
"status": "PERMISSION_DENIED"
}
}
I've tried giving the API owner access, but I guess I'm doing the permissions wrong.
Thanks for any help!