def GetEscrowClient(server_url, credentials, login_type=None): try: hostname = urlparse.urlparse(server_url)[1] if login_type is None or login_type == 'clientlogin': opener = base_client.BuildClientLoginOpener(hostname, credentials) else: raise NotImplementedError() fvclient = client.FileVaultClient(server_url, opener) fvclient.GetAndValidateMetadata() return fvclient except base_client.Error as e: raise Error(e)
def _Authenticate(self, error_func): self._ShowLoggingInMessage() try: credentials = base_client.GetOauthCredentials() except (RuntimeError, base_client.AuthenticationError) as e: error_func(unicode(e)) return opener = base_client.BuildOauth2Opener(credentials) client_ = client.FileVaultClient(self.server_url, opener) try: client_.GetAndValidateMetadata() except base_client.MetadataError as e: error_func(unicode(e)) return return client_