我正在使用 Google Cloud Endpoints 在 Python 中为 Android 应用程序编写后端。当我尝试运行 Google 的 API Explorer 以在开发服务器 (localhost) 上测试我的 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 的文档支持这一点:
端点需要 SSL。 (https://cloud.google.com/appengine/docs/python/endpoints/)
“开发 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)?
谢谢。
最佳答案
解决方法由 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")
关于python - 在开发服务器(在本地主机上)上运行适用于 Google Cloud Endpoints 的 API Explorer 不再有效,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28228860/