我在使用之前未获得过的 Google Custom Search API 时收到 403“调用者没有权限”错误

问题描述 投票:0回答:1

当我调用 Google 自定义搜索 API 时,出现以下错误:

{
  "error": {
    "code": 403,
    "message": "The caller does not have permission",
    "errors": [
      {
        "message": "The caller does not have permission",
        "domain": "global",
        "reason": "forbidden"
      }
    ],
    "status": "PERMISSION_DENIED"
  }
}

我之前多次使用过这个 API,唯一的区别是我使用了不同的 Google 云帐户和 API 密钥。我在我的 Google Cloud 项目中启用了自定义搜索 API,当我在 Google Cloud Console 中查看使用情况时,它显示 100% 错误,并且图表显示所有 403 错误。我还启用了 Places API,并且它工作得很好。为什么我会收到此错误?

我已尝试设置 OAuth 同意屏幕,但我很确定这仅在我使用 OAuth 令牌而不是 API 密钥时才相关,并且此 API 的文档仅告诉我如何使用 API 密钥。

google-cloud-platform google-custom-search
1个回答
0
投票

确保您正在使用的 API 密钥已启用

Custom search API

在 GCloud 控制台中,检查此处的限制:

https://console.cloud.google.com/apis/credentials?project=<YOUR_PROJECT_HERE>

应启用“自定义搜索 API”。

© www.soinside.com 2019 - 2024. All rights reserved.