Skip to content

Commit f33ee95

Browse files
authored
Merge pull request #78 from Keeper-Security/device-approve
Device approve command added
2 parents 273b7f0 + 2179565 commit f33ee95

File tree

6 files changed

+521
-7
lines changed

6 files changed

+521
-7
lines changed

README.md

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,15 @@ Below is a complete example demonstrating authentication, vault synchronization,
139139

140140
```python
141141
import sqlite3
142+
import getpass
143+
142144
from keepersdk.authentication import login_auth, configuration, endpoint
143145
from keepersdk.vault import sqlite_storage, vault_online, vault_record
144146

145147
# Initialize configuration and authentication context
146148
config = configuration.JsonConfigurationStorage()
147-
keeper_endpoint = endpoint.KeeperEndpoint(config)
149+
server = 'keepersecurity.com' # can be set to keepersecurity.com, keepersecurity.com.au, keepersecurity.jp, keepersecurity.eu, keepersecurity.ca, govcloud.keepersecurity.us
150+
keeper_endpoint = endpoint.KeeperEndpoint(config, keeper_server=server)
148151
login_auth_context = login_auth.LoginAuth(keeper_endpoint)
149152

150153
# Authenticate user
@@ -158,11 +161,11 @@ while not login_auth_context.login_step.is_final():
158161
if isinstance(login_auth_context.login_step, login_auth.LoginStepDeviceApproval):
159162
login_auth_context.login_step.send_push(login_auth.DeviceApprovalChannel.KeeperPush)
160163
elif isinstance(login_auth_context.login_step, login_auth.LoginStepPassword):
161-
password = PromptSession().prompt('Enter password: ', is_password=True)
164+
password = getpass.getpass('Enter password: ')
162165
login_auth_context.login_step.verify_password(password)
163166
elif isinstance(login_auth_context.login_step, login_auth.LoginStepTwoFactor):
164167
channel = login_auth_context.login_step.get_channels()[0]
165-
code = PromptSession().prompt(f'Enter 2FA code for {channel.channel_name}: ', is_password=True)
168+
code = getpass.getpass(f'Enter 2FA code for {channel.channel_name}: ')
166169
login_auth_context.login_step.send_code(channel.channel_uid, code)
167170
else:
168171
raise NotImplementedError()
@@ -201,6 +204,8 @@ if isinstance(login_auth_context.login_step, login_auth.LoginStepConnected):
201204
print(f'Record Type: {record.record_type}')
202205

203206
print("-" * 50)
207+
vault.close()
208+
keeper_auth.close()
204209
```
205210

206211
**Important Security Notes:**

0 commit comments

Comments
 (0)