工作我下面從這個官方鏈接教程:https://developers.google.com/sheets/quickstart/python蟒蛇)谷歌電子表格:更新API不與403
我沒有執行「quickstart.py」來驗證。 之後,我再次運行'quickstart.py',並在本教程中看到'https://docs.google.com/spreadsheets/d/1BxiMVs0XRA5nFMdKvBdBZjgmUUqptlbs74OgvE2upms/edit#gid=0'的數據。
我的確改變了電子表格的ID我自己的ID,並使其通過該方法獲得從我的電子表格中的數據:service.spreadsheets().values().get().execute()
但我的目標是將數據添加到我的電子表格,所以我使用的方法「更新「如下:
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))
然後,我得到了一個錯誤:
googleapiclient.errors.HttpError: https://sheets.googleapis.com/v4/spreadsheets/MY_SPREADSHEET_ID/values/A2%3AD?alt=json returned "Request had insufficient authentication scopes.">
我不知道爲什麼會這樣erorr當試圖更新我的表,爲什麼這個錯誤發生當試圖從我的表中獲取數據時不會發生(如果它是由身份驗證引起的,方法'get'也應該導致它!)
謝謝。
請請參閱[此鏈接](http://stackoverflow.com/questions/35846446/google-cloud-vision-api-request-had-insufficient-authentication-scopes/36059258) – Eugene
@Eugene感謝您的鏈接,但當然,我已經發現該帖子,它不是'gcloud',而是'python – LKM