【问题标题】:google flex endpoint 403 forbidden谷歌 flex 端点 403 被禁止
【发布时间】:2017-05-25 16:49:36
【问题描述】:

我开发了一些 google flex 端点。它们在本地工作,但是当我部署应用程序(gcloud app deploy)时,我得到一个 http 状态 403 禁止。我正在使用 ajax 像这样调用端点:

var echoEndpoint = function() {
  $.ajax(userBaseUrl+'/echo', {
    headers: {'Authorization': 'Bearer ' + userIdToken},
    type: 'GET',
    data: "key=my special key"
  })
}

我正在使用 apikey 保护端点并在标头中传递 userIdToken。上面的代码产生了 403 禁止。但是,如果我删除标题,它就可以工作。尽管没有用户令牌。这是不会产生 403 的代码

  var echoEndpoint = function() {
  $.ajax(userBaseUrl+'/echo', {
    type: 'GET',
    data: "key=my special key"
  })
}

这是我的 openapi.yaml 的路径部分 .....

     paths:
      "/echo":
        get:
          description: "Echo a test message."
          operationId: "echo"
          produces:
          - "application/json"
          responses:
            200:
              description: "Echo"
              schema:
                $ref: "#/definitions/echoMessage"
          x-security:
          - firebase:
              audiences:
              - "my project-id"
....
definitions:
  echoMessage:
    properties:
      message:
        type: "string"

我是否需要在我的 openapi.yaml 中指定要在请求中发送标头?如果是这样,如何以及在哪里?我试图将它放在定义部分,但在尝试部署时会产生 INVALID_ARGUMENT 错误。

【问题讨论】:

    标签: google-cloud-endpoints google-app-engine-python google-flexible


    【解决方案1】:

    您是否如本例所示在“securityDefinitions”中定义了“firebase”(https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/appengine/flexible/endpoints/openapi.yaml#L108)?

    【讨论】:

      猜你喜欢
      • 2016-09-10
      • 1970-01-01
      • 2019-05-12
      • 2015-01-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-26
      相关资源
      最近更新 更多