I am working on a web app based on Google App Engine (Webapp2/Python and ndb). I am using the Google OAuth2 authentication and storing in a custom User Entity of my ndb the googleId I get through users.get_current_user().user_id(). Thus this entity has both a id (automatically provided by the ndb) and this property called googleId which is set by me. I use this user object as common ancestor of the other used data I store in the ndb.
This approach is quite annoying because to avoid multiple ndb queries (one for each request) I have to store in session the id of the currently logged user, its googled id AND verify whether it is different from the currently logged user.
I have therefore thought to use the googleId as the KEY of the ndb entity and use it in the ancestor queries. Like
mu = MyUser(id = users.get_current_user().user_id())
mu.put()
It works perfectly but I was wondering if there could be any valid reason not to do so (i.e. the googleId may be longer than the maximum size of the ndb id properties, etc.)