2

I would like to connect and make request on a Google Sheet I've access with my personal Google account. I went on console.google.com and I created a new project for this purpose. I activated Google Sheet API too, and generated an API key.

I tried to use the Google Sheet v4 API with a curl request on a sheet:

https://sheets.googleapis.com/v4/spreadsheets/sheetId/values/Feuille%20!A1:D5?key=xxx

But the response I've got back is:

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

Do you have any information on this issue? I tried to search on Google but no viable solution was answered for my purpose.

Thanks.

Pyrrha
  • 159
  • 2
  • 12

1 Answers1

1

How about this answer?

Issue:

The reason of the error is as follows.

  • If you want to access to the Spreadsheet using the API key, it is required to publicly share the Spreadsheet.
  • API key can access to the publicly shared Spreadsheet with the GET method.

Solution:

  • As a test case, when you shared publicly your Spreadsheet, you can retrieve the values from the Spreadsheet using the endpoint.
  • If you don't want to share publicly the Spreadsheet, please use the access token retrieved from OAuth2 and service account.

References:

If this was not the direction you want, I apologize.

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • Thanks for your answer. I will check OAuth2 auth method and will keep you in touch. There is information that can't be exposed publicly on this sheet, so the second method is more adapted for my use case. – Pyrrha Oct 11 '19 at 09:36
  • @Tristan Dietz Thank you for replying. When the Spreadsheet cannot be shared publicly, it is required to use the access token. When you use the access token from OAuth2, is this answer useful? https://stackoverflow.com/a/42822060/7108653 – Tanaike Oct 11 '19 at 22:55