使用1Password Python库提取凭证时Windows用户遇MissingCredentials错误的求助
1Password Python库提取凭证时Windows用户遇MissingCredentials错误的求助
我现在在用一款叫“OnePassword python client”的Python库,用来和我的1Password实例交互,从名为“Employee”的保险箱里提取API凭证。
Python函数代码:
def authenticate(base_endpoint, api_key, api_secret): op = OnePassword() available_vaults = op.list_vaults() employee_vault = next((vault for vault in available_vaults if vault["name"] == "Employee"), None) if not employee_vault: print("No Employee vault found") items = op.list_items(vault=employee_vault["id"]) addepar_item = next((item for item in items if item["title"] == "Addepar API"), None) if not addepar_item: print("Please check that Addepar API item exists in 1Password") item_details = op.get_item(uuid=addepar_item["id"], fields=["username", "credential"]) if not item_details: print("Please check that Addepar API item credentials exists in 1Password") api_key = item_details["username"] api_secret = item_details["credential"] base_endpoint = "https://myfirm.addepar.com/api/v1/"
这个函数在Mac上运行完全正常,但Windows用户却遇到了下面的错误:
Windows用户错误信息:
C:\Users\User\PyCharmMiscProject\.venv\Scripts\python.exe C:\Users\User\PyCharmMiscProject\Main.py ⚠ Please enter an Entity ID: 123 Traceback (most recent call last): File "C:\Users\User\PyCharmMiscProject\Main.py", line 180, in <module> entity_attributes = get_entity_attributes(entity_id) File "C:\Users\User\PyCharmMiscProject\Main.py", line 32, in get_entity_attributes base_endpoint, api_key, api_secret = authenticate(base_endpoint="", api_key="", api_secret="") ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "C:\Users\User\PyCharmMiscProject\Main.py", line 11, in authenticate op = OnePassword() File "C:\Users\User\PyCharmMiscProject\.venv\Lib\site-packages\onepassword.py", line 52, in __init__ raise MissingCredentials() onepassword.MissingCredentials Process finished with exit code 1
我的分析:
我把错误追踪到了onepassword库的这段代码里,感觉问题可能和bin_path有关,但我自己是Mac用户,不太清楚Windows上的情况:
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()
希望有人能指点下,Windows用户这边可能是哪里配置不对导致的这个问题?
备注:内容来源于stack exchange,提问作者William
相关产品推荐
相关产品推荐

