Getting PERMISSION_DENIED when try to access Google Sheets with API Key

痞子三分冷 提交于 2019-12-11 05:47:37

问题


If I try to get data from Google Sheets with a basic spreadsheets.values.get request like this

https://sheets.googleapis.com/v4/spreadsheets/1p7sFt.....gRu9A/values/Sheet!1A1:L7?key=AIza.....oTXg it works.

But, if I add more parameters to the request it fails. Ex:

https://sheets.googleapis.com/v4/spreadsheets/1p7sFt.....gRu9A/values/Sheet1!A1:L7**?majorDimension=COLUMNS**?key=AIza.....oTXg

and returns:

{
  "error": {
    "code": 403,
    "message": "The request cannot be identified with a client project. Please pass a valid API key with the request.",
    "status": "PERMISSION_DENIED"
  }
}

回答1:


Use ampersand & for multiple query string parameters, not multiple ?

https://sheets.googleapis.com/v4/spreadsheets/1p7sFt.....gRu9A/values/Sheet1A1:L7**?majorDimension=COLUMNS**&key=AIza.....oTXg


来源:https://stackoverflow.com/questions/39723512/getting-permission-denied-when-try-to-access-google-sheets-with-api-key

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!