当前位置: 首页>>代码示例>>Python>>正文


Python keyring.delete_password方法代码示例

本文整理汇总了Python中keyring.delete_password方法的典型用法代码示例。如果您正苦于以下问题:Python keyring.delete_password方法的具体用法?Python keyring.delete_password怎么用?Python keyring.delete_password使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在keyring的用法示例。


在下文中一共展示了keyring.delete_password方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: reset_credentials

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def reset_credentials(self, service_name, username, new_secret_items=None):
        """
        Removes a username/password from KeyRing
        and replaces with a new one if desired.

        :param service_name: (str)
            The service name to remove.

        :param username: (str)
            The username to remove the password for.

        :param new_secret_items: (list, default None)
            The new secret item(s) to assign to the username if desired.

        :return: (None)
        """
        try:
            keyring.delete_password(service_name, username)
        except keyring.errors.PasswordDeleteError:
            pass

        if new_secret_items:
            new_pass = self._join_password_items(new_secret_items)
            keyring.set_password(service_name, username, new_pass) 
开发者ID:zbarge,项目名称:stocklook,代码行数:26,代码来源:security.py

示例2: refresh_access_token

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def refresh_access_token(self):
        if self._refresh_token is None:
            raise ValueError("no refresh token available with which to refresh authorization credentials")

        resp = _requests.post(
            url=self._token_endpoint,
            data={'grant_type': 'refresh_token',
                  'client_id': self._client_id,
                  'refresh_token': self._refresh_token},
            headers=self._headers,
            allow_redirects=False
        )
        if resp.status_code != _StatusCodes.OK:
            self._expired = True
            # In the absence of a successful response, assume the refresh token is expired. This should indicate
            # to the caller that the AuthorizationClient is defunct and a new one needs to be re-initialized.

            _keyring.delete_password(_keyring_service_name, _keyring_access_token_storage_key)
            _keyring.delete_password(_keyring_service_name, _keyring_refresh_token_storage_key)
            return
        self._initialize_credentials(resp) 
开发者ID:lyft,项目名称:flytekit,代码行数:23,代码来源:auth.py

示例3: delete_temporary_credential

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def delete_temporary_credential(host, user, store_temporary_credential=False):
    if (IS_MACOS or IS_WINDOWS) and keyring:
        new_target = convert_target(host, user)
        try:
            keyring.delete_password(new_target, user.upper())
        except Exception as ex:
            logger.debug("Failed to delete credential in the keyring: err=[%s]",
                         ex)
    elif IS_LINUX and store_temporary_credential:
        delete_temporary_credential_file() 
开发者ID:snowflakedb,项目名称:snowflake-connector-python,代码行数:12,代码来源:auth.py

示例4: delete_password

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def delete_password(self, account):
        try:
            import keyring
            keyring.delete_password(self.identifier, account)
        except:
            pass	# don't care - silently fail

# singleton 
开发者ID:EDCD,项目名称:EDMarketConnector,代码行数:10,代码来源:config.py

示例5: delete_password

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def delete_password(self, name, username):
        if not self.is_available():
            return

        import keyring
        import keyring.errors

        name = self.get_entry_name(name)

        try:
            keyring.delete_password(name, username)
        except (RuntimeError, keyring.errors.KeyringError):
            raise KeyRingError(
                "Unable to delete the password for {} from the key ring".format(name)
            ) 
开发者ID:python-poetry,项目名称:poetry,代码行数:17,代码来源:password_manager.py

示例6: delete_pypi_token

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def delete_pypi_token(self, name):
        if not self.keyring.is_available():
            return self._config.auth_config_source.remove_property(
                "pypi-token.{}".format(name)
            )

        self.keyring.delete_password(name, "__token__") 
开发者ID:python-poetry,项目名称:poetry,代码行数:9,代码来源:password_manager.py

示例7: delete_http_password

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def delete_http_password(self, name):
        auth = self.get_http_auth(name)
        if not auth or "username" not in auth:
            return

        try:
            self.keyring.delete_password(name, auth["username"])
        except KeyRingError:
            pass

        self._config.auth_config_source.remove_property("http-basic.{}".format(name)) 
开发者ID:python-poetry,项目名称:poetry,代码行数:13,代码来源:password_manager.py

示例8: clear_auth

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def clear_auth(appname=None, authfile=None, cookiejar=None):
    '''Clear all authentication data and delete related files'''

    appname   = appname   or APPNAME
    authfile  = authfile  or AUTHFILE
    cookiejar = cookiejar or COOKIEJAR

    authfiles = [cookiejar]

    log.info("Clearing all authentication data")

    if keyring:
        try:
            log.debug("Removing credentials from keyring")
            keyring.delete_password(appname, appname)
        except AttributeError as e:
            log.warning("Error removing keyring credentials. Outdated library? (%s)", e)
    else:
        authfiles.append(authfile)

    for auth in authfiles:
        try:
            log.debug("Deleting '%s'", auth)
            os.remove(auth)
        except OSError as e:
            log.debug(e)

    log.info("Finished clearing authentication") 
开发者ID:MestreLion,项目名称:humblebundle,代码行数:30,代码来源:humblebundle.py

示例9: write

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def write(self, *args):
        """See ConfigParser.write().  Also writes secure items to keystore."""
        ConfigParser.write(self, *args)
        if self.keyring_available:
            for key, thing in self._unsaved.items():
                action = thing[0]
                value = thing[1]
                if action == 'set':
                    keyring.set_password(self.keyring_name, key, value)
                elif action == 'delete':
                    try:
                        keyring.delete_password(self.keyring_name, key)
                    except:
                        pass
        self._unsaved = {} 
开发者ID:jantman,项目名称:biweeklybudget,代码行数:17,代码来源:config.py

示例10: delete

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def delete(name):
    keyring.delete_password(DOMAIN, name) 
开发者ID:debrouwere,项目名称:google-analytics,代码行数:4,代码来源:keyring.py

示例11: delete_account

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def delete_account(yes=False, index=None, email=None, account_id=None):
    click.echo('All OneDrive accounts associated with user "%s":\n' % context.user_name)
    all_account_ids = print_all_accounts(context)
    click.echo()

    if index is None and email is None and account_id is None:
        # Print account table and ask which account to delete.
        index = click.prompt('Please enter row number of the account to delete (CTRL+C to abort)', type=int)

    if index is not None:
        if isinstance(index, int) and 0 <= index < len(all_account_ids):
            account_id = all_account_ids[index]
        else:
            error('Index is not a valid row number.')
            return

    if email is not None:
        try:
            account_id = email_to_account_id(context, email, all_account_ids)
        except Exception as e:
            error(str(e))
            return

    if account_id is not None:
        if account_id not in all_account_ids:
            error('Account ID "%s" is not found.' % account_id)
            return
        account = context.get_account(account_id)
        prompt_text = 'Are you sure to delete account %s?' % account
        if yes or click.confirm(prompt_text):
            context.delete_account(account_id)
            keyring.delete_password(OneDriveAPISession.KEYRING_SERVICE_NAME, get_keyring_key(account_id))
            save_context(context)
            success('Successfully deleted account from onedrived.')
        else:
            click.echo('Operation canceled.') 
开发者ID:xybu,项目名称:onedrived-dev,代码行数:38,代码来源:od_pref.py

示例12: test_save_and_load

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def test_save_and_load(self):
        keydict = {self.session.SESSION_ARG_KEYNAME: 'mock_key'}
        self.session.save_session(**keydict)
        session = od_api_session.OneDriveAPISession.load_session(**keydict)
        self.assertEqual(self.session.token_type, session.token_type)
        self.assertEqual(self.session.scope, session.scope)
        self.assertEqual(self.session.access_token, session.access_token)
        self.assertEqual(self.session.client_id, session.client_id)
        self.assertEqual(self.session.client_secret, session.client_secret)
        self.assertEqual(self.session.refresh_token, session.refresh_token)
        keyring.delete_password(od_api_session.OneDriveAPISession.KEYRING_SERVICE_NAME, 'mock_key') 
开发者ID:xybu,项目名称:onedrived-dev,代码行数:13,代码来源:test_api_session.py

示例13: set_password

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def set_password(self, key, token):
        try:
            import keyring
        except ImportError:
            install_keyring()
            self._initialize_keyring()
            import keyring

        try:
            # check for and delete existing credential
            old_token = keyring.get_password(key, self._USERNAME)
            if old_token is not None:
                keyring.delete_password(key, self._USERNAME)
            logger.debug('Setting credential: %s', key)
            keyring.set_password(key, self._USERNAME, token)
        except Exception as ex:  # pylint: disable=broad-except
            # store credentials in azuredevops config directory if keyring is missing or malfunctioning
            if sys.platform.startswith(self._LINUX_PLATFORM):
                logger.warning('Failed to store PAT using keyring; falling back to file storage.')
                logger.warning('You can clear the stored credential by running az devops logout.')
                logger.warning('Refer https://aka.ms/azure-devops-cli-auth to know more on sign in with PAT.')
                logger.debug('Keyring failed. ERROR :%s', ex)
                logger.debug('Storing credentials in the file: %s', self._PAT_FILE)
                creds_list = self._get_credentials_list()
                if key not in creds_list.sections():
                    creds_list.add_section(key)
                    logger.debug('Added new entry to PAT file : %s ', key)
                creds_list.set(key, self._USERNAME, token)
                self._commit_change(creds_list)
            else:
                raise CLIError(ex) 
开发者ID:Azure,项目名称:azure-devops-cli-extension,代码行数:33,代码来源:credential_store.py

示例14: clear_password

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def clear_password(self, key):
        try:
            import keyring
        except ImportError:
            install_keyring()
            self._initialize_keyring()
            import keyring
        if sys.platform.startswith(self._LINUX_PLATFORM):
            keyring_token = None
            file_token = None
            try:
                keyring_token = keyring.get_password(key, self._USERNAME)
                if keyring_token:
                    keyring.delete_password(key, self._USERNAME)
            except Exception as ex:  # pylint: disable=broad-except
                logger.debug("%s", ex)
            finally:
                file_token = self.get_PAT_from_file(key)
                if file_token:
                    self.delete_PAT_from_file(key)
            if(keyring_token is None and file_token is None):
                raise CLIError(self._CRDENTIAL_NOT_FOUND_MSG)
        else:
            try:
                keyring.delete_password(key, self._USERNAME)
            except keyring.errors.PasswordDeleteError:
                raise CLIError(self._CRDENTIAL_NOT_FOUND_MSG)
            except RuntimeError as ex:  # pylint: disable=broad-except
                raise CLIError(ex) 
开发者ID:Azure,项目名称:azure-devops-cli-extension,代码行数:31,代码来源:credential_store.py

示例15: clear_config

# 需要导入模块: import keyring [as 别名]
# 或者: from keyring import delete_password [as 别名]
def clear_config(self):
        keyring.delete_password(const.NAMESPACE, 'rackspace_username')
        keyring.delete_password(const.NAMESPACE, 'rackspace_api_key')
        keyring.delete_password(const.NAMESPACE, 'aws_profile_name') 
开发者ID:rackerlabs,项目名称:yolo,代码行数:6,代码来源:client.py


注:本文中的keyring.delete_password方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。