def create_logout_url(dest_url, _auth_domain=None):
  """Computes the logout URL for this request and specified destination URL,
     for both federated login App and Google Accounts App.

  Args:
    dest_url: String that is the desired final destination URL for the user
              once logout is complete. If 'dest_url' does not have a host
              specified, we will use the host from the current request.

  Returns:
    Logout URL as a string
  """
  req = user_service_pb.CreateLogoutURLRequest()
  resp = user_service_pb.CreateLogoutURLResponse()
  req.set_destination_url(dest_url)
  if _auth_domain:
    req.set_auth_domain(_auth_domain)

  try:
    apiproxy_stub_map.MakeSyncCall('user', 'CreateLogoutURL', req, resp)
  except apiproxy_errors.ApplicationError, e:
    if (e.application_error ==
        user_service_pb.UserServiceError.REDIRECT_URL_TOO_LONG):
      raise RedirectTooLongError
    else:
      raise e
def create_logout_url(dest_url, _auth_domain=None):
    """Computes the logout URL and specified destination URL for the request.

  This function works for both federated login applications and Google Accounts
  applications.

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

  Returns:
    Logout URL as a string.
  """
    req = user_service_pb.CreateLogoutURLRequest()
    resp = user_service_pb.CreateLogoutURLResponse()
    req.set_destination_url(dest_url)
    if _auth_domain:
        req.set_auth_domain(_auth_domain)

    try:
        apiproxy_stub_map.MakeSyncCall('user', 'CreateLogoutURL', req, resp)
    except apiproxy_errors.ApplicationError, e:
        if (e.application_error ==
                user_service_pb.UserServiceError.REDIRECT_URL_TOO_LONG):
            raise RedirectTooLongError
        else:
            raise e
Example #3
0
    def test_user_api_call(self):
        logout_response = user_service_pb.CreateLogoutURLResponse()
        logout_response.set_logout_url(
            USER_LOGOUT_URL % urllib.quote('http://machine:8080/crazy_logout'))

        expected_remote_response = remote_api_pb.Response()
        expected_remote_response.set_response(logout_response.Encode())

        logout_request = user_service_pb.CreateLogoutURLRequest()
        logout_request.set_destination_url('/crazy_logout')

        self._assert_remote_call(expected_remote_response, logout_request,
                                 'user', 'CreateLogoutURL')