Pyrrha
Pyrrha

Reputation: 159

Authenticate with Google Sheet API v4

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.

Upvotes: 2

Views: 1379

Answers (1)

Tanaike
Tanaike

Reputation: 201388

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.

Upvotes: 1

Related Questions