Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/onepassword/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ class Client:

@classmethod
async def authenticate(
cls, auth: str | DesktopAuth, integration_name: str, integration_version: str
cls, auth: str | DesktopAuth,
integration_name: str, integration_version: str,
shared_library_path: str = ""
) -> Client:
config = new_default_config(
auth=auth,
Expand All @@ -28,7 +30,7 @@ async def authenticate(
)

if isinstance(auth, DesktopAuth):
core = DesktopCore(auth.account_name)
core = DesktopCore(auth.account_name, shared_library_path)
else:
core = UniffiCore()

Expand Down
9 changes: 6 additions & 3 deletions src/onepassword/desktop_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from onepassword.errors import raise_typed_exception


def find_1password_lib_path():
def find_1password_lib_path(custom_location: str = ""):
os_name = platform.system()

# Define paths based on OS
Expand All @@ -32,6 +32,9 @@ def find_1password_lib_path():
]
else:
raise OSError(f"Unsupported operating system: {os_name}")

if isinstance(custom_location, str) and len(custom_location) > 0:
locations.insert(0, custom_location)

for lib_path in locations:
if os.path.exists(lib_path):
Expand All @@ -40,9 +43,9 @@ def find_1password_lib_path():
raise FileNotFoundError("1Password desktop application not found")

class DesktopCore:
def __init__(self, account_name: str):
def __init__(self, account_name: str, library_path: str = ""):
# Determine the path to the desktop app.
path = find_1password_lib_path()
path = find_1password_lib_path(library_path)

self.lib = ctypes.CDLL(path)
self.account_name = account_name
Expand Down