google-cloud-platform - GCP 端点 : The caller does not have permission after requesting API key in query

标签 google-cloud-platform permissions google-cloud-endpoints api-key

尝试将 Google Cloud 平台与已部署的 GKE 后端结合使用。

我有一个用于端点的 swagger 文件,在不使用安全性时可以正常工作。

我在 swagger 文件中添加了 api key 定义:

paths:
  /create:
    post:
      ...
      security:
        - api_key: []
      
securityDefinitions:
  api_key:
    type: "apiKey"
    name: "key"
    in: "query"

现在,如果我尝试发帖,我会得到预期的结果

{
    "code": 16,
    "message": "Method doesn't allow unregistered callers (callers without established identity). Please use API Key or other form of API consumer identity to call this API.",
    "details": [
        {
            "@type": "type.googleapis.com/google.rpc.DebugInfo",
            "stackEntries": [],
            "detail": "service_control"
        }
    ]
}

很好,现在我在 GCP 的凭据部分创建了一个 API key enter image description here

我更新发布请求以包含 ?key=API_KEY 并收到以下错误:

{
    "code": 13,
    "message": "\b#The caller does not have permission",
    "details": [
        {
            "@type": "type.googleapis.com/google.rpc.DebugInfo",
            "stackEntries": [],
            "detail": "service_control"
        }
    ]
}

我找不到关于此错误的任何信息,这是否意味着我的 API key 无权使用此端点?如果是这样,我该如何解决?

最佳答案

确认您拥有 required services enabled

gcloud services enable servicemanagement.googleapis.com
gcloud services enable servicecontrol.googleapis.com
gcloud services enable endpoints.googleapis.com

同时启用您的端点服务gcloud services enable ENDPOINTS_SERVICE_NAME

关于google-cloud-platform - GCP 端点 : The caller does not have permission after requesting API key in query,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61501446/

相关文章:

java - Android运行时权限——如何实现

php - 未经网络许可执行php脚本

python - 使用 webapp2 session 的 Google Cloud Endpoints 身份验证

google-cloud-platform - BigQuery - 在哪里可以找到错误流?

google-app-engine - 初始化 Cloud Engine 时还有其他人遇到 "unknown error"吗?

google-cloud-platform - stackdriver 请求包含无效参数

android - 如何在 Android 的 Cloud Endpoints 构建器中禁用 GZipContent

docker - Terraform - GCloud 容器注册表示例

ios - Facebook iOS SDK 请求权限 publish_actions,但用户需要再次输入密码

google-app-engine - 生成 Cloud Endpoint 时遇到错误且未完成