Google Apis:API 密钥无效

Google Apis:API 密钥无效
curl 'https://www.googleapis.com/youtube/v3/subscriptions?key=$KEY'
{
  "error": {
    "code": 400,
    "message": "API key not valid. Please pass a valid API key.",
    "errors": [
      {
    "message": "API key not valid. Please pass a valid API key.",
    "domain": "global",
    "reason": "badRequest"
      }
    ],
    "status": "INVALID_ARGUMENT",
    "details": [
      {
    "@type": "type.googleapis.com/google.rpc.ErrorInfo",
    "reason": "API_KEY_INVALID",
    "domain": "googleapis.com",
    "metadata": {
      "service": "youtube.googleapis.com"
    }
      }
    ]
  }
}

如您所见,在各种事情中,出现了错误

API 密钥无效。请传递有效的 API 密钥。

为什么?

以下是您从我的配置页面看到的一些内容(https://console.cloud.google.com/apis/credentials)由 Google Cloud 提供 https://i.stack.imgur.com/cGZuo.png


@StarCat 你说得对,我是用脚本来运行它的。如果我直接从 bash 终端运行该命令,就会得到以下结果

{
  "error": {
    "code": 403,
    "message": "Requests from referer \u003cempty\u003e are blocked.",
    "errors": [
      {
        "message": "Requests from referer \u003cempty\u003e are blocked.",
        "domain": "global",
        "reason": "forbidden"
      }
    ],
    "status": "PERMISSION_DENIED",
    "details": [
      {
        "@type": "type.googleapis.com/google.rpc.ErrorInfo",
        "reason": "API_KEY_HTTP_REFERRER_BLOCKED",
        "domain": "googleapis.com",
        "metadata": {
          "consumer": "projects/480710366740",
          "service": "youtube.googleapis.com"
        }
      }
    ]
  }
}

相关内容