我在部署的appengine应用程序上遇到问题:它没有使用Google的API资源管理器返回我的位置。
我确实定义了一个./datastore_models/location.py文件:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from google.appengine.ext import ndb
from google.appengine.api import search
from endpoints_proto_datastore.ndb import EndpointsModel
class Location(EndpointsModel):
name = ndb.StringProperty(required=True, verbose_name="Name")
description = ndb.TextProperty(required=True, verbose_name="Description")
address = ndb.StringProperty(required=True, verbose_name="Address")
coordinate = ndb.GeoPtProperty(required=False, verbose_name="Coordinate")
enable_geocode = ndb.BooleanProperty(default=False, verbose_name="Enable geocode")
active = ndb.BooleanProperty(default=True, verbose_name="Active")
owner = ndb.UserProperty(required=False, verbose_name="Owner")
我确实有一个简单的./main.py文件:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import endpoints
from protorpc import remote
from datastore_models.location import Location
WEB_CLIENT_ID = 'ID.apps.googleusercontent.com'
@endpoints.api(name='uemd', version='v1',
description='API for locations, objects and events',
audiences=[WEB_CLIENT_ID, endpoints.API_EXPLORER_CLIENT_ID])
class UemDAPI(remote.Service):
@Location.method(user_required=True, request_fields=('name', 'description', 'address', 'enable_geocode'),
path='location', http_method='POST', name='location.insert')
def LocationInsert(self, location):
location.owner = endpoints.get_current_user()
location.put()
return location
@Location.method(user_required=True, request_fields=('id',),
path='location/{id}', http_method='GET', name='location.get')
def LocationGet(self, location):
if not location.from_datastore:
raise endpoints.NotFoundException('Location not found.')
return location
@Location.query_method(user_required=True, query_fields=('active', 'limit', 'order', 'pageToken'),
path='locations', name='location.list')
def LocationList(self, query):
return query.filter(Location.owner == endpoints.get_current_user())
app = endpoints.api_server([UemDAPI], restricted=False)
当我现在调用“GET https://uemd-core.appspot.com/_ah/api/uemd/v1/locations”时,在使用POST方法之前,我没有收到我创建的位置。我收到了:
{
"kind": "uemd#locationItem",
"etag": "\"llW4_dZC50NEF69z_hZurfpZb1s/wnbopBN8xedxeOulX5Nry_3uwCw\""
}
执行“GET https://uemd-core.appspot.com/_ah/api/uemd/v1/location/5634387206995968”会按预期返回一个位置。
在Appengine Logs中,我看到以下调试消息:
id_token verification failed: Can't parse header:ɭ�
但我也看到了这个消息,该方法确实返回了一个位置......
在dev_appserver.py上运行相同的查询会引发:
RuntimeError: UnicodeDecodeError('utf8', "id_token verification failed: Can't parse header: \xc9\xad\xbd", 52, 53, 'invalid start byte')
到目前为止,我确实遵循了端点 - proto-datastore的示例,但我确实希望将我的数据存储模型存储在一个额外的目录(datastore_models)中。 location.insert和location.get方法正在运行,但没有location.list。所有这些方法都显示“无法解析标题”消息...我该如何解决这个问题?
干杯
我仍然遇到同样的问题。检索一个位置确实有效,多个没有。
Traceback (most recent call last):
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 1302, in communicate
req.respond()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 831, in respond
self.server.gateway(self).respond()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/lib/cherrypy/cherrypy/wsgiserver/wsgiserver2.py", line 2115, in respond
response = self.req.server.wsgi_app(self.env, self.start_response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/wsgi_server.py", line 269, in __call__
return app(environ, start_response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/request_rewriter.py", line 311, in _rewriter_middleware
response_body = iter(application(environ, wrapped_start_response))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 148, in __call__
self._flush_logs(response.get('logs', []))
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/tools/devappserver2/python/request_handler.py", line 284, in _flush_logs
apiproxy_stub_map.MakeSyncCall('logservice', 'Flush', request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 94, in MakeSyncCall
return stubmap.MakeSyncCall(service, call, request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_stub_map.py", line 328, in MakeSyncCall
rpc.CheckSuccess()
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/api/apiproxy_rpc.py", line 156, in _WaitImpl
self.request, self.response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 200, in MakeSyncCall
self._MakeRealSyncCall(service, call, request, response)
File "/Applications/GoogleAppEngineLauncher.app/Contents/Resources/GoogleAppEngine-default.bundle/Contents/Resources/google_appengine/google/appengine/ext/remote_api/remote_api_stub.py", line 234, in _MakeRealSyncCall
raise pickle.loads(response_pb.exception())
RuntimeError: UnicodeDecodeError('utf8', "id_token verification failed: Can't parse header: \xc9\xad\xbd", 52, 53, 'invalid start byte')
答案 0 :(得分:0)
这与endpoints-proto-datastore无关。这是googleappengine的一个问题,似乎它将在下一个版本(1.8.9)中修复:
https://code.google.com/p/googleappengine/issues/detail?id=10285
干杯