Google App Engine配置端点API

时间:2016-11-01 06:31:15

标签: python google-app-engine google-cloud-endpoints endpoints gae-python27

我在配置Endpoints API时遇到问题。我使用的任何代码,从我自己的代码到网站上的google示例都会失败并返回相同的跟踪

WARNING  2016-11-01 06:16:48,279 client.py:229] no scheduler thread, scheduler.run() will be invoked by report(...)
Traceback (most recent call last):
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/control/client.py", line 225, in start
self._thread.start()
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/api/background_thread/background_thread.py", line 108, in start
start_new_background_thread(self.__bootstrap, ())
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/api/background_thread/background_thread.py", line 87, in start_new_background_thread
raise ERROR_MAP[error.application_error](error.error_detail)
FrontendsNotSupported
INFO     2016-11-01 06:16:48,280 client.py:327] created a scheduler to control flushing
INFO     2016-11-01 06:16:48,280 client.py:330] scheduling initial check and flush
INFO     2016-11-01 06:16:48,288 client.py:804] Refreshing access_token
/home/vladimir/projects/sb_fork/sb/lib/vendor/urllib3/contrib/appengine.py:113: AppEnginePlatformWarning: urllib3 is using URLFetch on Google App Engine sandbox instead of sockets. To use sockets directly instead of URLFetch see https://urllib3.readthedocs.io/en/latest/contrib.html.
AppEnginePlatformWarning)
ERROR    2016-11-01 06:16:49,895 service_config.py:125] Fetching service config failed (status code 403)
ERROR    2016-11-01 06:16:49,896 wsgi.py:263] 
Traceback (most recent call last):
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 240, in Handle
handler = _config_handle.add_wsgi_middleware(self._LoadHandler())
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 299, in _LoadHandler
handler, path, err = LoadObject(self._handler)
File "/home/vladimir/sdk/google-cloud-sdk/platform/google_appengine/google/appengine/runtime/wsgi.py", line 85, in LoadObject
obj = __import__(path[0])
File "/home/vladimir/projects/sb_fork/sb/main.py", line 27, in <module>
api_app = endpoints.api_server([SolarisAPI,], restricted=False)
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/endpoints/apiserving.py", line 497, in api_server
controller)
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/control/wsgi.py", line 77, in add_all
a_service = loader.load()
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/control/service.py", line 110, in load
return self._load_func(**kw)
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/config/service_config.py", line 78, in fetch_service_config
_log_and_raise(Exception, message_template.format(status_code))
File "/home/vladimir/projects/sb_fork/sb/lib/vendor/google/api/config/service_config.py", line 126, in _log_and_raise
raise exception_class(message)
Exception: Fetching service config failed (status code 403)
INFO     2016-11-01 06:16:49,913 module.py:788] default: "GET / HTTP/1.1" 500 -

我的app.yaml配置类似于新的Endpoints Migrating to 2.0文档状态:

- url: /_ah/api/.*
  script: api.solaris.api_app

main.py将API导入应用:

api_app = endpoints.api_server([SolarisAPI,], restricted=False)

我在这些版本中使用Google Cloud SDK:

Google Cloud SDK 132.0.0
app-engine-python 1.9.40
bq 2.0.24
bq-nix 2.0.24
core 2016.10.24
core-nix 2016.10.24
gcloud 
gsutil 4.22
gsutil-nix 4.22

2 个答案:

答案 0 :(得分:2)

您是否尝试过生成并上传该服务的OpenAPI配置?请参阅"Generating the OpenAPI configuration file"中名为"Deploying the OpenAPI configuration file"python library documentation的部分。

请注意,在生成过程的第2步中,您可能需要在命令前添加python(例如python lib/endpoints/endpointscfg.py get_swagger_spec ...),因为PyPi包现在不保留可执行文件权限

答案 1 :(得分:1)

摆脱&#34; FrontendsNotSupported&#34;你需要使用&#34; B *&#34;实例类。

错误&#34;异常:提取服务配置失败&#34;如果您按照https://cloud.google.com/endpoints/docs/frameworks/python/quickstart-frameworks-python中的步骤操作,我们就应该离开。正如Brad已经指出的那样,&#34; OpenAPI配置&#34;并且需要生成的环境变量才能使服务配置正常工作。