How to use the keyring.set_password function in keyring

To help you get started, we’ve selected a few keyring examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github and3rson / nineapi / View on Github external
from unittest import TestCase
from nineapi.client import Client, APIException
import os
import sys
import keyring

#While using the program the follwing command should be run only once,the system will store the creds.
password="" #This should be removed after setting the password

class APITest(TestCase):
    def setUp(self):
        self.client = Client()
        self.username = username
        self.password = keyring.get_password('9gag',username)

    def test_log_in_good(self):
        response = self.client.log_in(self.username, self.password)
        self.assertEqual(response, True)

    def test_log_in_bad(self):
        self.assertRaises(APIException, lambda: self.client.log_in(self.username, self.password + 'wrong'))

    def test_get_posts(self):
github ClumsyLee / net.tsinghua / src / View on Github external
def save_accounts(accounts, filename):
    content = {}
    for acc in accounts:
        # Save password.
        set_password(SERVICE_NAME, acc.username, acc.password)
        # Save infos.
        infos = acc.infos
        infos['is_md5'] = acc.is_md5
        infos['last_check'] = acc.last_check
        infos['valid'] = acc.valid

        content[acc.username] = infos

    yaml.dump(content, open(filename, 'w', encoding='utf-8'),
github cevoaustralia / aws-google-auth / aws_google_auth / View on Github external
                config.password = util.Util.get_password("Google Password: ")
            config.password = util.Util.get_password("Google Password: ")

        # Validate Options

        google_client = google.Google(config, args.save_failure_html)
        saml_xml = google_client.parse_saml()
        logging.debug('%s: saml assertion is: %s', __name__, saml_xml)

        # If we logged in correctly and we are using keyring then store the password
        if config.keyring and keyring_password is None:
                "aws-google-auth", config.username, config.password)

        # We now have a new SAML value that can get cached (If the user asked
        # for it to be)
        if args.saml_cache:
            config.saml_cache = saml_xml

    # The amazon_client now has the SAML assertion it needed (Either via the
    # cache or freshly generated). From here, we can get the roles and continue
    # the rest of the workflow regardless of cache.
    amazon_client = amazon.Amazon(config, saml_xml)
    roles = amazon_client.roles

    # Determine the provider and the role arn (if the the user provided isn't an option)
    if config.role_arn in roles and not config.ask_role:
        config.provider = roles[config.role_arn]
github jrnl-org / jrnl / jrnl / View on Github external
def set_keychain(journal_name, password):
    import keyring
    if password is None:
            keyring.delete_password('jrnl', journal_name)
        except RuntimeError:
        keyring.set_password('jrnl', journal_name, password)
github spillz / picty / modules / picty / plugins / View on Github external
            #TODO: If system keyring daemon is not running, an assertion will throw here -- need to be more informative to the user
            password = None
        if password is not None:
        dfd = d.get_form_data()
        if response == 1:
            password = dfd['password']
            remember = dfd['remember']
            if remember and password != '':
                    keyring.set_password(KEYRING_SERVICE_NAME, user, password)
                    #TODO: If system keyring daemon is not running, an error will be raised -- need to be more informative to the user
            elif not remember:
                    # only available in newer versions
                    keyring.delete_password(KEYRING_SERVICE_NAME, user)
                    # maybe give a warning?
            return password
        return None
github lvillani / ansible-tools / ansibletools / cli / View on Github external
def set_secret(name, secret):
    """Stores a secret into the keyring, creating or updating the relevant stanza
    in `ansible.cfg' in the process.

    c = load_ansible_cfg()

    if not c.has_section("vault"):

    c.set(CFG_SECTION, CFG_OPTION, name)

    with open(get_ansible_cfg_path(), "w") as fp:

    keyring.set_password(KEYRING_SERVICE, name, secret)
github dmitriy-serdyuk / twinnet-asr / libs / Theano / theano / misc / View on Github external
user = input("Username: ")
    pw = getpass.getpass("Password: ")

    auth_request = {
        "scopes": [
        "note": "IPython tools",
        "note_url": "",
    response ='',
                             auth=(user, pw), data=json.dumps(auth_request))
    token = json.loads(response.text)['token']
    keyring.set_password('github', fake_username, token)
    return token
github mozilla / mozilla_ci_tools / mozci / utils / View on Github external
def _prompt_password_storing(https_username):
    https_password = getpass.getpass()
    store_password = raw_input(
        "Do you want to store your password in encrypted form (y or n)? ")

    if store_password == "y":
        keyring.set_password(KEYRING_KEY, https_username, https_password)

    return https_password
github lyft / flytekit / flytekit / clis / auth / View on Github external
"refresh_token": "bar",
          "id_token": "baz",
          "token_type": "Bearer"
        response_body = auth_token_resp.json()
        if "access_token" not in response_body:
            raise ValueError('Expected "access_token" in response from oauth server')
        if "refresh_token" in response_body:
            self._refresh_token = response_body["refresh_token"]

        access_token = response_body["access_token"]
        id_token = response_body["id_token"]
        refresh_token = response_body["refresh_token"]

        _keyring.set_password(_keyring_service_name, _keyring_access_token_storage_key, access_token)
        _keyring.set_password(_keyring_service_name, _keyring_id_token_storage_key, id_token)
        _keyring.set_password(_keyring_service_name, _keyring_refresh_token_storage_key, refresh_token)
        self._credentials = Credentials(access_token=access_token, id_token=id_token)
github picklepete / pyicloud / pyicloud / View on Github external
def store_password_in_keyring(username, password):
    return keyring.set_password(