Skip to content

Commit bfc0422

Browse files
authored
Modify Bitwarden client to handle missing email
Remove email parameter requirement and fetch email if not provided.
1 parent 90d0f8c commit bfc0422

1 file changed

Lines changed: 12 additions & 1 deletion

File tree

src/vaultwarden/clients/bitwarden.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def __init__(
2222
):
2323
# if one of the parameters is None, raise an exception
2424
if not all(
25-
[url, email, password, client_id, client_secret, device_id]
25+
[url, password, client_id, client_secret, device_id]
2626
):
2727
raise BitwardenError("All parameters are required")
2828
self.email = email
@@ -96,6 +96,17 @@ def _set_connect_token(self):
9696
"identity/connect/token", headers=headers, data=payload
9797
)
9898
self._connect_token = ConnectToken.model_validate_json(resp.text)
99+
100+
if self.email is None:
101+
headers = {
102+
"Authorization": f"Bearer {self._connect_token.access_token}",
103+
"content-type": "application/json; charset=utf-8",
104+
"Accept": "*/*",
105+
}
106+
resp = self._http_client.get(
107+
"api/accounts/profile", headers=headers)
108+
self.email = resp.json()["email"]
109+
99110
import vaultwarden.models.bitwarden
100111

101112
self._connect_token.master_key = make_master_key(

0 commit comments

Comments
 (0)