Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Something's wrong with my permissions and I can't figure out what

I'm very new to programming, and I'm trying to use Google's API to run a script that will read and write to a spreadsheet in Google Sheets. Based on the error messages I'm getting, I think the script itself is fine, but I haven't properly configured my permissions in Google Cloud Console. Which makes sense, because I've never used an API before and don't entirely know what I'm doing. Can someone help me troubleshoot this, please?

The error message I'm getting is:

Traceback (most recent call last):
File "C:\PATH\FILENAME.py", line 17, in <module>
spreadsheet = client.open(spreadsheet_name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\PATH\Python\Python311\Lib\site-packages\gspread\client.py", line 170, in open
self.list_spreadsheet_files(title, folder_id),
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\PATH\Python\Python311\Lib\site-packages\gspread\client.py", line 145, in list_spreadsheet_files
res = self.request("get", url, params=params).json()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\PATH\Python\Python311\Lib\site-packages\gspread\client.py", line 92, in request
raise APIError(response)
gspread.exceptions.APIError: {'code': 403, 'message': 'Request had insufficient authentication scopes.', 'errors': [{'message': 'Insufficient Permission', 'domain': 'global', 'reason': 'insufficientPermissions'}], 'status': 'PERMISSION_DENIED', 'details': [{'@type': 'type.googleapis.com/google.rpc.ErrorInfo', 'reason': 'ACCESS_TOKEN_SCOPE_INSUFFICIENT', 'domain': 'googleapis.com', 'metadata': {'service': 'drive.googleapis.com', 'method': 'google.apps.drive.v3.DriveFiles.List'}}]}

1 0 810
0 REPLIES 0
Top Labels in this Space
Top Solution Authors