How do i verify user in database in google appengine app ( can anyone recommend the best way to do user authentication for google appengine app)?
<p>I have following code in <code>models.py</code> i can sort database by only key but not by string ?</p>

<pre><code>from google.appengine.ext import ndb

class Roles(ndb.Model):
name = ndb.StringProperty()
owner = ndb.KeyProperty(kind='User')
created = ndb.DateTimeProperty(required=True, auto_now_add = True)
class RESTMeta:
    user_owner_property = 'owner'
    include_output_properties = ['name']

class Users(ndb.Model):
name = ndb.StringProperty()
email = ndb.StringProperty()
password = ndb.StringProperty()
roles = ndb.KeyProperty(kind='Roles')
owner = ndb.KeyProperty(kind='User')
created = ndb.DateTimeProperty(required=True, auto_now_add = True)
class RESTMeta:
    user_owner_property = 'owner'
    include_output_properties = ['name']
</code></pre>

<p>And the following in <code>api.py</code></p>

<pre><code>app = webapp2.WSGIApplication([
RESTHandler(
  '/api/roles', # The base URL for this model's endpoints
  models.Roles, # The model to wrap
  permissions={
    'GET': PERMISSION_ANYONE,
    'POST': PERMISSION_ANYONE,
    'PUT': PERMISSION_OWNER_USER,
    'DELETE': PERMISSION_ADMIN
  },
  # Will be called for every PUT, right before the model is saved (also supports callbacks for GET/POST/DELETE)
  put_callback=lambda model, data: model
),
RESTHandler(
  '/api/users', # The base URL for this model's endpoints
  models.Users, # The model to wrap
  permissions={
    'GET': PERMISSION_ANYONE,
    'POST': PERMISSION_ANYONE,
    'PUT': PERMISSION_OWNER_USER,
    'DELETE': PERMISSION_ADMIN
  },
  # Will be called for every PUT, right before the model is saved (also supports callbacks for GET/POST/DELETE)
  put_callback=lambda model, data: model
)],debug=True, config = config)
</code></pre>

<p>I can successfully <code>get</code> by key in <code>api\users?q=roles=key('key')</code></p>

<p>How do i get specific user by <strong>String</strong> <code>api\users?q=email=String('String')</code></p>

<p><strong>The Question is how do I do user auth for google appengine app</strong></p>

<p>You seem to be asking so many questions in one.</p>

<p>To get user by email, simply do this:</p>

<pre><code>users = Users.query(Users.email=='query_email').fetch(1)
#note fetch() always returns a list
if users:
    user_exists = True
else:
    user_exists = False
</code></pre>

<p>Please note, you may need to <a href="https://cloud.google.com/appengine/docs/java/config/indexconfig#creating_indexes_using_the_development_server" rel="nofollow">update your datastore index</a> to support that query. The easiest way to do it is to first run the code in your local development server, and the index will be automatically updated for you.</p>

<p>To answer your second questions, for user authentication I would recommend <a href="https://docs.djangoproject.com/en/1.10/topics/auth/" rel="nofollow">Django's in-built User Authentication</a>. Please note that you can always run vanilla <a href="https://cloud.google.com/python/django/flexible-environment" rel="nofollow">django on appengine with a Flexible VM</a> using <a href="https://cloud.google.com/sql/docs/" rel="nofollow">CloudSQL</a> instead of the Datastore.</p>

<p>Alternatively, you could use the <a href="https://cloud.google.com/appengine/docs/python/users/" rel="nofollow">Appengine Users API</a>, though your users would need to have Google Accounts.</p>

python django google-app-engine jinja2