Appengine endpoints-proto-datastore issue with user_required: No records returned

366 views Asked by At

I'm facing an issue on a deployed appengine app: It does not return me my locations using Google's API explorer.

I did define a ./datastore_models/location.py file:

#!/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")

And I do have got a simple ./main.py file:

#!/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)

When I now do call "GET https://uemd-core.appspot.com/_ah/api/uemd/v1/locations" I do not receive the locations I did create before using the POST method. I do just receive:

{
 "kind": "uemd#locationItem",
 "etag": "\"llW4_dZC50NEF69z_hZurfpZb1s/wnbopBN8xedxeOulX5Nry_3uwCw\""
}

Executing "GET https://uemd-core.appspot.com/_ah/api/uemd/v1/location/5634387206995968" does return one location as expected.

In the Appengine Logs I see the following debug message:

id_token verification failed: Can't parse header:ɭ�

But I also see this message for the method which does return a single location...

Running the same query on the dev_appserver.py raises:

RuntimeError: UnicodeDecodeError('utf8', "id_token verification failed: Can't parse header: \xc9\xad\xbd", 52, 53, 'invalid start byte')

So far I did follow the examples of endpoints-proto-datastore, but I did want to store my datastore models in an extra directory (datastore_models). The location.insert and location.get methods are working, but no the location.list. All of those methods do show the "Can't parse header" message... How can I fix this?

Cheers

I do still have got the same issue. Retrieving one location does work, multiple doesn't.

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')
1

There are 1 answers

0
decurgia On BEST ANSWER

This is not related to endpoints-proto-datastore. It's an issue with googleappengine and it seems like it's going to be fixed in the next release (1.8.9):

https://code.google.com/p/googleappengine/issues/detail?id=10285

Cheers