尝试使用 API 键访问 Google 工作表时获取 PERMISSION_DENIED
Getting PERMISSION_DENIED when try to access Google Sheets with API Key
如果我尝试使用这样的基本 spreadsheets.values.get 请求从 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
和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"
}
}
使用符号 &
表示多个查询字符串参数,而不是多个 ?
https://sheets.googleapis.com/v4/spreadsheets/1p7sFt.....gRu9A/values/Sheet1A1:L7**?majorDimension=COLUMNS**&key=AIza.....oTXg
如果我尝试使用这样的基本 spreadsheets.values.get 请求从 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
和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"
}
}
使用符号 &
表示多个查询字符串参数,而不是多个 ?
https://sheets.googleapis.com/v4/spreadsheets/1p7sFt.....gRu9A/values/Sheet1A1:L7**?majorDimension=COLUMNS**&key=AIza.....oTXg