generated from bitwarden/template
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget.py
More file actions
56 lines (43 loc) · 1.47 KB
/
get.py
File metadata and controls
56 lines (43 loc) · 1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env python3
"""Request a credential using the cached session.
Requires a prior pairing via pair.py.
Usage:
python3 get.py --domain example.com
"""
import argparse
import sys
from bw_remote_rs import RemoteClient
def main() -> int:
parser = argparse.ArgumentParser(
description="Request a credential via Bitwarden Remote Access (Rust backend)"
)
parser.add_argument("--proxy", default="wss://ap.lesspassword.dev", help="Proxy server URL")
parser.add_argument("--domain", required=True, help="Domain to request credentials for")
parser.add_argument(
"--identity", default="python-remote",
help="Identity keypair name — stored at ~/.bw-remote/<name>.key",
)
args = parser.parse_args()
client = RemoteClient(proxy_url=args.proxy, identity_name=args.identity)
try:
# Connect using the single cached session
client.connect()
cred = client.request_credential(args.domain)
if cred.username:
print(f"Username: {cred.username}")
if cred.password:
print(f"Password: {cred.password}")
if cred.totp:
print(f"TOTP: {cred.totp}")
if cred.uri:
print(f"URI: {cred.uri}")
if cred.notes:
print(f"Notes: {cred.notes}")
return 0
except Exception as e:
print(f"Error: {e}", file=sys.stderr)
return 1
finally:
client.close()
if __name__ == "__main__":
sys.exit(main())