通过谷歌云端点访问谷歌应用引擎rest api

问题描述

https://github.com/GoogleCloudPlatform/endpoints-quickstart

这有一个简单的flask API,它部署在Google App Engine - Flex env 上。 此处使用 Google Cloud Endpoints 作为 API 管理。

我已将其部署在我的 Google App Engine 上,并且按预期工作。到目前为止一切顺利。

我尝试修改 openapi.yaml 以包含安全密钥。

swagger: "2.0"
info:
  title: "Testing"
  description: "Testing a cloud endpoint"
  version: "1.0.0"
# This field will be replaced by the deploy_api.sh script.
host: "my-project-id.appspot.com"
schemes:
  - "https"
paths:
  "/airportName":
    get:
      security:
        - ApiKeyAuth: []      
      description: "Get the airport name for a given IATA code."
      operationId: "airportName"
      parameters:
          -
          name: iata
          in: query
          required: true
          type: string
      responses:
        200:
          description: "Success."
          schema:
            type: string
        400:
          description: "The IATA code is invalid or missing."

securityDeFinitions:
  ApiKeyAuth:
    type: apiKey
    in: header
    name: X-API-Key

但是,仅通过 /airportName?iata=JFK 即可访问 REST API 端点。

我希望只有在标头中提供 X-API-Key 键值对时才能访问它。 我还应该做什么才能使 api 密钥正常工作?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)