Except as otherwise noted,
the content of this page is licensed under a Creative Commons
license, and examples are licensed under
an Apache
license.
Google Code offered in: 中文 - English - Português - Pусский - Español - 日本語
App Engine applications can authenticate users using Google Accounts. An application can redirect a user to a Google Accounts page to sign in or register for an account, or sign out. While a user is signed in to an application using a Google account, the application can access the user's email address and nickname. The application can also detect if the user is an administrator for the application, making it easy to implement admin-only areas of the application.
from google.appengine.api import users class MyHandler(webapp.RequestHandler): def get(self): user = users.get_current_user() if user: greeting = ("Welcome, %s! (<a href=\"%s\">sign out</a>)" % (user.nickname(), users.create_logout_url("/"))) else: greeting = ("<a href=\"%s\">Sign in or register</a>." % users.create_login_url("/")) self.response.out.write("<html><body>%s</body></html>" % greeting)