I'm following the tutorial from this official link : https://developers.google.com/sheets/quickstart/python
I did execute 'quickstart.py' to authenticated. After that, I ran 'quickstart.py' again and saw the data from 'https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0' as this tutorial gets.
I did change spreadsheet ID to my own id and make it to get the data from my spreadsheet by the method :service.spreadsheets().values().get().execute()
But my goal is to add data to my spreadsheet, so I used the method 'update' as below:
rangeName = 'A2:D'
body['range'] = rangeName
body['majorDimension'] = 'ROWS'
body['values'] = ['test','test','test','test']
result = service.spreadsheets().values().update(
spreadsheetId=spreadsheetId, range=rangeName, body=body).execute()
print('result:'+str(result))
Then I got an error :
googleapiclient.errors.HttpError: https://sheets.googleapis.com/v4/spreadsheets/MY_SPREADSHEET_ID/values/A2%3AD?alt=json returned "Request had insufficient authentication scopes.">
I don't know why this erorr occurs when trying to update my sheet and why this error doesn't occur when trying to get data from my sheet.(If it is cause by authentication, the method 'get' should cause it too!)
Thank you.