Skip to main content

Keeper SDK for Python 3

Project description

Keeper-Security/keeper-sdk-python

Keeper SDK for Python

Installation

pip install keepersdk

Clone source code

$ git clone https://github.com/Keeper-Security/keeper-sdk-python

Example

import os
from login import auth, configuration, endpoint
from vault import sqlite_storage, vault_online, vault_record

config_filename = os.path.join(os.path.dirname(__file__), 'config.json')
config = configuration.JsonConfigurationStorage(file_name=config_filename)
keeper_endpoint = endpoint.KeeperEndpoint(config)
login_auth = auth.LoginAuth(keeper_endpoint)
login_auth.login('username@company.com')

while not login_auth.login_step.is_final():
    if isinstance(login_auth.login_step, auth.LoginStepPassword):
        password = input('Enter password: ')
        login_auth.login_step.verify_password(password)
    if isinstance(login_auth.login_step, auth.LoginStepTwoFactor):
        channel = login_auth.login_step.get_channels()[0]
        code = input(f'Enter 2FA code for {channel.channel_name}: ')
        login_auth.login_step.send_code(channel.channel_uid, code)
    else:
        raise NotImplementedError()

if isinstance(login_auth.login_step, auth.LoginStepConnected):
    keeper_auth = login_auth.login_step.keeper_auth()
    vault_storage = sqlite_storage.SqliteVaultStorage(file_name=':memory:',
                                                      vault_owner=keeper_auth.auth_context.username)
    vault = vault_online.VaultOnline(keeper_auth, vault_storage)
    vault.sync_down()

    # List records
    for record in vault.records():
        print(f'Title: {record.title}')
        if record.version == 2:
            legacy_record = vault.load_record(record.record_uid)
            if isinstance(legacy_record, vault_record.PasswordRecord):
                print(f'Username: {legacy_record.login}')

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

keepersdk-0.9.10-py3-none-any.whl (234.0 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page