Google Sheets API: The caller does not have permission
Asked Answered
C

3

16

I'm trying to read the document from the cron:

https://sheets.googleapis.com/v4/spreadsheets/<sheet_id>?key=<api_key>

My document is available to anyone with the link.


My #1 key settings:    
Application restrictions:

 - IP addresses (web servers, cron jobs, etc.) - I added my external IP address.
 - API restrictions - none

My #2 key settings:
Application restrictions:

 - IP addresses (web servers, cron jobs, etc.) - I added my external IP address.
 - API restrictions - Google Sheets API

My #3 key settings:
Application restrictions:

 - IP addresses (web servers, cron jobs, etc.) - I added my external IP address.
 - API restrictions - Google Sheets API, Google Drive API

My #4 key settings:
Application restrictions:

 - IP addresses (web servers, cron jobs, etc.) - none
 - API restrictions - Google Sheets API

My #5 key settings:
Application restrictions:

 - IP addresses (web servers, cron jobs, etc.) - none
 - API restrictions - Google Sheets API, Google Drive API

My #6 key settings:
Application restrictions:

 - IP addresses (web servers, cron jobs, etc.) - none
 - API restrictions - none

When I try to open a document with each key, I get a 403 error:

{
  "error": {
    "code": 403,
    "message": "The caller does not have permission",
    "status": "PERMISSION_DENIED"
  }
}

The same error occurs when using the API Explorer (https://developers.google.com/sheets/api/reference/rest/v4/spreadsheets/get).

At the same time, the document itself opens successfully from a link from any computer and from any browser even to unauthorized users.

This problem began on July 9 at 09:35 PM (UTC+0).

Prior to this error, I successfully received data from the document using the #1 key settings.

Update:

I found another strange nuance: on all other documents there is no such problem. An error is observed on one particular document. I compared the access settings with others - they are identical.

Update 2:

I tried to copy the table and open it via API - the error was the same. An hour later I tried again - it all worked.

Crossarm answered 10/7, 2018 at 9:10 Comment(8)
I have the same problem. It worked today in the morning but got the error this afternoon after no change. Maybe it's a Google issue.Usa
This issue is driving me mad, I'm glad I found this post. Any official acknowledgement from Google about this?Mediatize
Same situation for me today. Tried generating new API keys and no luck. Hopefully it gets ironed out soon.Defroster
We are having the same issue, publicly available spreadsheet but PERMISSION_DENIED from the API... Must be something on Google's sideEpigene
Is there some way to make an official bug report to Google?Mediatize
Issue has been posted here: issuetracker.google.com/issues/111465512Mediatize
I am also experiencing this issue. If anyone is updated with a solution can they please share?Flower
It just worked on my public sheet!Psychotherapy
C
3

After seeing HoverPhoenix comment, I change access of My sheet to ** Anyone with link** on Viewer mode.

Example Access Image

After changing the access it is working properly. If Data security is the concern then the best option is to use OAuth 2.0 Client IDs as credentials.

Cudlip answered 19/8, 2020 at 11:15 Comment(0)
K
0

As @thinktwice said it is suggested to turn on the Anyone with the link option in the sheet.

I was using python and this created_spreadsheet.share('', role='reader', type='anyone') worked for me.

Kieger answered 4/10, 2020 at 17:12 Comment(0)
D
0

API key is for getting public spread sheets, if you want to get private ones, consider using a service account

Data answered 14/7, 2022 at 15:12 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.