The answer to this is somewhat similar to Simple Access API (Developer Key) with Google Cloud Endpoint (Python)
In users_id_token.py
, the request
object is a ProtoRPC object that parsed an incoming request. However, even if the actual user did not specify on of the keys 'bearer_token'
or 'access_token'
as part of the ProtoRPC message definition, if they were passed in the request as query parameters, they will be stored on the ProtoRPC object that is created.
To access them, the not-so-well-known method is used:
request.get_unrecognized_field_info(key)
Why is this important? To access fields
on an object, let's assume the attribute fields
was passed in through the request. Then if you have a request parsed into my_message
, you can access the fields
via
my_message.get_unrecognized_field_info('fields')
In ndb/model.py
, the query_method
method has a locally scoped function defined there which is called QueryFromRequestMethod
. In it, a ProtoRPC object is created directly:
request_entity = cls.FromMessage(request)
It is there where you'd want to use
request_entity.get_unrecognized_field_info('fields')
I would suggest either
- Using a patched version of the library that only works for your use case
- Submitting a fix to the library that allows for this customization in the method in a lightweight way
- Subclassing
endpoints_proto_datastore.ndb.EndpointsModel
and overriding thequery_method
method to do your special bidding.