This question is about authenticating using an API key when using Python to write to a Google sheet. Following the Getting Started example, I'm "discovering" the API using an URL:
service = discovery.build('sheets', 'v4', discoveryServiceUrl=
'https://sheets.googleapis.com/$discovery/rest?version=v4',
developerKey=APIKEY)
Passing an API key this way seems to work (it throws no exception.) After that, I try to update the spreadsheet with batchUpdate
:
service.spreadsheets().batchUpdate(spreadsheetId=SHEETID,
body={'requests': requests}).execute()
This throws a 401 HTTP error: "Request is missing required authentication credential." Other functions like values().clear()
result in the same error.
How can I pass an API key to discovered Python functions?