Google v4 app4 application request app4 receives an HTTP 401 response for public channels using an API key

This is very similar to another question that I answered here on how to get spreadsheet data, but I'm trying to add append data . spreadsheets. Here is my twist request:

curl -H "Content-Type: application/json" -X POST -d '{"range":"A1","majorDimension":"ROWS","values":["Frank2"]}' https://sheets.googleapis.com/v4/spreadsheets/{SPREADSHEET_ID}/values/A1:append?valueInputOption=RAW&key={API-KEY}

Here's the answer:

{
  "error": {
    "code": 401,
    "message": "The request does not have valid authentication credentials.",
    "status": "UNAUTHENTICATED"
  }
}

Is it possible to do this only with an API key, or am I doing something wrong? The documentation suggests that this is possible if the spreadsheet is publicly available.

+5
source share
3 answers

, . , API .

+6

https://developers.google.com/sheets/api/guides/authorizing#APIKey

:

Your application must use OAuth 2.0 to authorize requests. Other authorization protocols are not supported. If your application uses Google Sign-In, some aspects of authorization are processed for you.

0
source

Source: https://habr.com/ru/post/1662585/


All Articles