This part of the Python Guestbook code walkthrough shows how to authenticate users and display a customized greeting for the signed-in user.
This page is part of a multi-page tutorial. To start from the beginning and see instructions for setting up, go to Creating a Guestbook.
Signing in users
The MainPage
class defines a handler for HTTP GET
requests to the
root path '/'
. The handler checks to see whether a user is signed in:
If the user is already signed in to your application, the get_current_user()
method returns a User
object, and the app displays the users's nickname.
If the user has not signed in, the code redirects the user's browser to the
Google account sign-in screen. The Google account sign-in mechanism sends the
user back to the app after the user has signed in.
For more information, see the Users API.