Skip to content

Commit

Permalink
feat: adding otp fields (#62)
Browse files Browse the repository at this point in the history
* feat: add support for otp fields

Signed-off-by: Felipe Zipitria <fzipitria@life360.com>

* fix: adding test and new line split

---------

Signed-off-by: Felipe Zipitria <fzipitria@life360.com>
Co-authored-by: Felipe Zipitria <fzipitria@life360.com>
  • Loading branch information
dtpryce and fzipi360 authored May 28, 2024
1 parent 256f0f5 commit 83982a7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions onepassword/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,3 +445,13 @@ def get_item(uuid: str | bytes, fields: str | bytes | list | None = None):
else:
item = json.loads(read_bash_return("op item get {} --format=json".format(uuid), single=False))
return item

@staticmethod
def get_item_otp(uuid: str | bytes):
"""
Helper function to get the item otp, you can find the UUID you need using list_items
:param uuid: Uuid of the item you wish to get, no vault needed
:return: the otp of the item, if it exists
"""
return read_bash_return("op item get {} --otp".format(uuid), single=False).rstrip('\n')
6 changes: 6 additions & 0 deletions test/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ def test_get_items(self):
"""
pass

def test_get_item_otp(self):
"""
Without user interaction will not be signed in and be unable to list anything
"""
pass


if __name__ == '__main__':
unittest.main()

0 comments on commit 83982a7

Please sign in to comment.