当试图用API密钥访问Google Sheets时,得到了PERMISSION_DENIED。[英] Getting PERMISSION_DENIED when try to access Google Sheets with API Key

本文是小编为大家收集整理的关于当试图用API密钥访问Google Sheets时,得到了PERMISSION_DENIED。的处理/解决方法,可以参考本文帮助大家快速定位并解决问题,中文翻译不准确的可切换到English标签页查看源文。

问题描述

如果我尝试从Google表中获取基本电子表格的数据

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

但是,如果我向请求添加更多参数,则会失败. 例如:

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

和返回:

{
  "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"
  }
}

推荐答案

使用ampersand &用于多个查询字符串参数,而不是多个?

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

本文地址:https://www.itbaoku.cn/post/1937891.html

问题描述

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"
  }
}

推荐答案

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