Stay organized with collections
Save and categorize content based on your preferences.
The Users API provides functions for constructing URLs that allow the user to sign in or sign out, then be redirected back to your application.
UserService::createLoginUrl() and UserService::createLogoutUrl() each take a destination URL for the application, and return a URL for signing in or signing out that redirects back to the given URL afterward.
use google\appengine\api\users\User;use google\appengine\api\users\UserService;$user = UserService::getCurrentUser();if (isset($user)) { echo sprintf('Welcome, %s! (<a href="%s">sign out</a>)', $user->getNickname(), UserService::createLogoutUrl('/'));} else { echo sprintf('<a href="%s">Sign in or register</a>', UserService::createLoginUrl('/'));}
The development web server simulates Google Accounts using its own sign-in and sign-out facilities. When you sign in to your application on the development web server, the server prompts you for an email address to use for the session. See The Development Web Server for more information.
Tip: An easy way to restrict access to a part of your application to signed in users is to use the login: required configuration element for the URL handler. See Configuring an App.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Hard to understand","hardToUnderstand","thumb-down"],["Incorrect information or sample code","incorrectInformationOrSampleCode","thumb-down"],["Missing the information/samples I need","missingTheInformationSamplesINeed","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-03-05 UTC."],[[["The Users API allows developers to create URLs for user sign-in and sign-out actions, redirecting them back to the application afterward."],["`UserService::createLoginUrl()` and `UserService::createLogoutUrl()` functions generate the URLs for signing in and out, respectively, while requiring a destination URL for redirection."],["The development web server simulates Google Accounts with its sign-in/sign-out mechanisms, prompting for an email address when signing in locally."],["Access to specific parts of an application can be restricted to signed-in users using the `login: required` configuration element for URL handlers."],["This API is specific to first-generation runtimes in the App Engine standard environment and has different options in later versions."]]],[]]