【问题标题】:Running the API Explorer for Google Cloud Endpoints on a development server (on localhost) no longer works在开发服务器(本地主机上)上运行用于 Google Cloud Endpoints 的 API Explorer 不再有效
【发布时间】:2015-01-30 03:41:49
【问题描述】:

我正在使用 Google Cloud Endpoints 在 Python 中为 Android 应用程序编写后端。当我尝试在开发服务器 (localhost) 上运行 Google 的 API Explorer 来测试我的 API 时,它给了我一个关于 SSL 的错误:

403 Forbidden
    {
     "error": {
      "errors": [
       {
        "domain": "global",
        "reason": "sslRequired",
        "message": "SSL is required to perform this operation."
       }
      ],
      "code": 403,
      "message": "SSL is required to perform this operation."
     }
    }

Google 的文档支持这一点:

  1. 端点需要 SSL。 (https://cloud.google.com/appengine/docs/python/endpoints/)

  2. “开发 Web 服务器不支持 HTTPS 连接” cloud.google.com/appengine/docs/python/config/appconfig#Python_app_yaml_Secure_URLs

我有两个不方便的解决方法:使用 CURL 将命令发送到开发服务器(如以下站点所示)或仅测试已部署的版本。 API Explorer 非常方便,过去几年我每次使用它都可以使用它,最近一次是在 2014 年 8 月。

有谁知道 API Explorer 需要 SSL 是不是最近的变化?有没有办法在开发服务器上使用 API Explorer,正如这里所说的(https://cloud.google.com/appengine/docs/python/endpoints/test_deploy#running_and_testing_api_backends_locally)?

谢谢。

【问题讨论】:

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


    【解决方案1】:

    Tyler Rockwood 发现的变通方法...

    如果您从 @endpoints.api 注释中删除 hostname 字段,它会再次起作用:

    不行……

    @endpoints.api(name="blah", version="v1", description="Blah", hostname="causesfailure.appspot.com")
    

    会工作...

    @endpoints.api(name="blah", version="v1", description="Blah")
    

    或者(甚至是lamer)您可以在测试时将主机名设置为localhost

    @endpoints.api(name="blah", version="v1", description="Blah", hostname="localhost:8080")
    

    【讨论】:

      【解决方案2】:

      不要在@endpoints.api 注释中添加主机名

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2017-06-09
        • 2018-08-29
        • 1970-01-01
        • 2018-05-20
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多