Skip to main content

Provide route decorators for Google App Engine users

Project description

Flask Google App Engine Users

Provide route decorators for Google App Engine users.


Daniel 'Vector' Kerr (


Refer to LICENSE.txt.


pip install flask-gae-users

Sample Usage

Python Code

from flask import Flask, request, Response, jsonify
from flask_gae_users import GAEUsers
from flask_gae_users import GAENoUserException
from flask_gae_users import GAENotAdminException

app = Flask()
GAEUsers( app = app )

# Provide a response when a user is not logged in
@app.errorhandler( GAENoUserException )
def onAppNoUser( e ):
  body = "<p>You must log in to continue</p>"
  body = body + "<p><a href=\"" + app.get_login_url() + "\">Sign in</a></p>"
  return Response( body, status = 401 )

# Provide a response when a user is not an administrator
@app.errorhandler( GAENotAdminException )
def onAppNoUser( e ):
  body = "<p>You are not authorized to access this resource</p>"
  body = body + "<p><a href=\"" + app.get_logout_url() + "\">Sign in as a different user</a></p>"
  return Response( body, status = 403 )

# Create a user-protected route by adding the `require_user` decorator
@app.route( '/home', methods = [ 'GET' ] )
def routeHome():
  user = app.get_user()
  return jsonify( { 'user': repr( user ) } )

# Create an admin-protected route by adding the `require_admin` decorator
@app.route( '/admin', methods = [ 'GET' ] )
def routeAdmin():
  admin = app.get_user()
  return jsonify( { 'admin': repr( admin ) } )

# Run the flask application
if __name__ == '__main__': port = 8080 )

Run Server


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flask-gae-users, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size flask_gae_users-0.0.1-py2-none-any.whl (2.9 kB) File type Wheel Python version py2 Upload date Hashes View
Filename, size flask-gae-users-0.0.1.tar.gz (2.5 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page