Python 2.7 has reached end of supportand will bedeprecatedon January 31, 2026. After deprecation, you won't be able to deploy Python 2.7applications, even if your organization previously used an organization policy tore-enable deployments of legacy runtimes. Your existing Python2.7 applications will continue to run and receive traffic after theirdeprecation date. We recommend thatyoumigrate to the latest supported version of Python.

google.appengine.api.users module

Summary

The User Python datastore class to be used as a datastore data type.

Contents

google.appengine.api.users.CreateLoginURL(dest_url=None, _auth_domain=None, federated_identity=None)source

Computes the login URL for redirection.

Parameters
  • dest_url – String that is the desired final destination URL for the user once login is complete. Ifdest_url does not specify a host, the host from the current request is used.

  • federated_identity – Decommissioned, don’t use. Setting this to a non-None value raises a NotAllowedError

Returns

Login URL as a string. The login URL will use Google Accounts.

Raises

NotAllowedError – If federated_identity is not None.

google.appengine.api.users.CreateLogoutURL(dest_url, _auth_domain=None)source

Computes the logout URL and specified destination URL for the request.

This function works for Google Accounts applications.

Parameters

dest_url – String that is the desired final destination URL for the user after the user has logged out. Ifdest_url does not specify a host, the host from the current request is used.

Returns

Logout URL as a string.

exceptiongoogle.appengine.api.users.Errorsource

Bases: exceptions.Exception

Base User error type.

google.appengine.api.users.GetCurrentUser()source

Retrieves information associated with the user that is making a request.

Returns:

google.appengine.api.users.IsCurrentUserAdmin()source

Specifies whether the user making a request is an application admin.

Because administrator status is not persisted in the datastore,is_current_user_admin() is a separate function rather than a member function of theUser class. The status only exists for the user making the current request.

Returns

True if the user is an administrator; all other user types returnFalse.

exceptiongoogle.appengine.api.users.NotAllowedErrorsource

Bases:google.appengine.api.users.Error

The requested redirect URL is not allowed.

exceptiongoogle.appengine.api.users.RedirectTooLongErrorsource

Bases:google.appengine.api.users.Error

The generated redirect URL was too long.

classgoogle.appengine.api.users.User(email=None, _auth_domain=None, _user_id=None, federated_identity=None, federated_provider=None, _strict_mode=True)source

Bases: object

Provides the email address, nickname, and ID for a user.

A nickname is a human-readable string that uniquely identifies a Google user, akin to a username. For some users, this nickname is an email address, but for other users, a different nickname is used.

A user is a Google Accounts user.

federated_identity andfederated_provider are decommissioned and should not be used.

auth_domain()source

Obtains the user’s authentication domain.

Returns

A string containing the authentication domain. This method is internal and should not be used by client applications.

email()source

Returns the user’s email address.

federated_identity()source

Decommissioned, don’t use.

Returns

A string containing the federated identity of the user. If the user is not a federated user,None is returned.

federated_provider()source

Decommissioned, don’t use.

Returns

A string containing the federated provider. If the user is not a federated user,None is returned.

nickname()source

Returns the user’s nickname.

The nickname will be a unique, human readable identifier for this user with respect to this application. It will be an email address for some users, and part of the email address for some users.

Returns

The nickname of the user as a string.

user_id()source

Obtains the user ID of the user.

Returns

A permanent unique identifying string orNone. If the email address was set explicity, this will returnNone.

exceptiongoogle.appengine.api.users.UserNotFoundErrorsource

Bases:google.appengine.api.users.Error

No email argument was specified, and no user is logged in.

google.appengine.api.users.create_login_url(dest_url=None, _auth_domain=None, federated_identity=None)source

Computes the login URL for redirection.

Parameters
  • dest_url – String that is the desired final destination URL for the user once login is complete. Ifdest_url does not specify a host, the host from the current request is used.

  • federated_identity – Decommissioned, don’t use. Setting this to a non-None value raises a NotAllowedError

Returns

Login URL as a string. The login URL will use Google Accounts.

Raises

NotAllowedError – If federated_identity is not None.

google.appengine.api.users.create_logout_url(dest_url, _auth_domain=None)source

Computes the logout URL and specified destination URL for the request.

This function works for Google Accounts applications.

Parameters

dest_url – String that is the desired final destination URL for the user after the user has logged out. Ifdest_url does not specify a host, the host from the current request is used.

Returns

Logout URL as a string.

google.appengine.api.users.get_current_user()source

Retrieves information associated with the user that is making a request.

Returns:

google.appengine.api.users.is_current_user_admin()source

Specifies whether the user making a request is an application admin.

Because administrator status is not persisted in the datastore,is_current_user_admin() is a separate function rather than a member function of theUser class. The status only exists for the user making the current request.

Returns

True if the user is an administrator; all other user types returnFalse.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025-06-16 UTC.