google-cloud-endpoints - 上次部署的 API 和实际使用的 API 之间似乎不匹配
问题描述
根据 Google Cloud Console > Endpoints > Services > Deployment History,这是当前部署的 API 规范:
swagger: "2.0"
info:
title: "JSON Ingester"
description: "Receive JSON files, transform and load them."
version: "1.0.0"
host: "project-id-123.appspot.com"
schemes:
- "https"
paths:
"/upload":
post:
summary: "ETL JSON file."
security:
- api_key: []
operationId: "upload"
consumes:
- multipart/form-data
parameters:
- in: formData
name: file
type: string
responses:
200:
description: "File uploaded."
schema:
type: string
400:
description: "Error during file upload."
securityDefinitions:
api_key:
type: "apiKey"
name: "apikey"
in: "query"
但是不接受密钥“apikey”-相反,它需要在我几个小时前部署的 openapi.yaml 中指定的“密钥”。
这有效,但它不应该:
$ curl -X POST -F "file=@data/file_6.json" https://project-id-123.appspot.com/upload\?key\=AIzaS...Eaoog
这不起作用,而它应该:
$ curl -X POST -F "file=@data/file_6.json" https://project-id-123.appspot.com/upload\?apikey\=AIzaS...Eaoog
{
"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"
}
]
}
我必须清除缓存还是什么?
为了部署我使用的 API:
gcloud endpoints services deploy "./openapi.yaml"
有任何想法吗?
解决方案
您在部署 ESP 时使用了什么rollout_strategy?如果未指定,默认为“固定”。您应该使用“托管”
另请通过 CLI“gcloud endpoints configs describe”检查生成的服务配置。检查其 system_parameters 文件以查看您的新“apikey”是否已正确创建。
推荐阅读
- html - pdf 未在本地目录的 html 中显示
- html - 在较小的父 div 中缩小不同宽度的图像
- javascript - 解析 .scss 函数体的正则表达式(SCSS Parser via JS)
- dart - Flutter:如何在没有android底部导航栏的情况下显示屏幕键盘来聚焦文本字段?
- sulu - Sulu:是否可以在没有图像格式的情况下使用自定义测量来获得调整大小的图像
- build - 颤动的iOS构建失败(ld:找不到-lPods-Runner的库)
- rxjs - RxJS 和 IxJS 的区别?
- postgresql - Vapor 3/Fluent for Postgres:如何进行 SELECT DISTINCT 查询?
- regex - 不允许匹配 2 个或更多点的正则表达式?
- amazon-web-services - 在 API Gateway 中基于 cognito 身份池身份查找 cognito userpool uset