Returning `onepassword.MissingCredentials` Error
Appreciating this is for bugs, and not StackOverflow...I am unsure if 'unofficial' Windows support was added in 01/06 release, so raising this as a 'potential' issue.
My function (fully functioning on Mac
from onepassword import OnePassword
def authenticate(base_endpoint, api_key, api_secret):
op = OnePassword()
# Getting vault list
available_vaults = op.list_vaults()
# Searching for Employee Vault
employee_vault = next((vault for vault in available_vaults if vault["name"] == "Employee"), None)
# Getting Employee Vault ID
items = op.list_items(vault=employee_vault["id"])
# Searching for Addepar API item in Employee vault
addepar_item = next((item for item in items if item["title"] == "Addepar API"), None)
# Getting Addepar API item details
item_details = op.get_item(uuid=addepar_item["id"], fields=["username", "credential"])
# Saving item credentials in variables for API usage
api_key = item_details["username"]
api_secret = item_details["credential"]
Getting the following on Windows (works fine on Mac) so unsure if a Windows or install issue (please close if so) -
Traceback
File "C:\Users\william\PyCharmProjects\CLIProject\.venv\lib\site-packages\onepassword.py, line 53, in __init__
raise MissingCredentials()
onepassword.MissingCredentials
Traceback Reference
This looks to be referencing the class OnePassword(object). Specifically:
class OnePassword(object):
def __init__(self, secret=None, token=None, shorthand=None, bin_path=""):
self.op = os.path.join(bin_path, "op")
if secret is not None:
self.shorthand = str(uuid4())
self.session_token = self.get_access_token(secret, shorthand=self.shorthand)
elif token is not None and shorthand is not None:
self.shorthand = shorthand
self.session_token = token
else:
raise MissingCredentials()
System Details Windows 11 version 24H2 Python 3.12.8 1Password CLI 2.24.0 1Password 8.10.56
We did not add full Windows support as you can see in the README there is no suggestion it works. However, I am sure in parts it does. We would need some help in implementing something within the frameworks we have already and did start trying on the v2-windows branch, like I said it just needs some love. So please do feel enabled to submit a PR and we can go from there!
I was getting the same error after trying to get a script working on a new machine. I looked at the code... There is no MissingCredentials error. There's also no onepassword.py file. So I did some investigating and I found this:
https://github.com/lettdigital/onepassword-python/blob/master/onepassword.py#L52
On the Pypi registry, this package is named 1password, but I had accidentally installed this other onepassword package since that's what the imported package name was in the script I was trying to get working. This also duplicates issue #48.
I don't know anything about the Windows support of this library, but you might want to try again after installing the correct version. It might work better than this other library we installed accidentally.