Skip to content

Commit dd60775

Browse files
committed
Add example on fetching TOTP code
1 parent 3782753 commit dd60775

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

example/example.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,29 @@ async def main():
3939
section_id=None,
4040
value="jeff",
4141
),
42+
ItemField(
43+
id="onetimepassword",
44+
title="one-time-password",
45+
field_type="Totp",
46+
section_id="totpsection",
47+
value="rfbhsnjchsecbhsedchb",
48+
),
4249
],
43-
sections=[ItemSection(id="", title="")],
50+
sections=[ItemSection(id="", title=""), ItemSection(id="totpsection", title="")],
4451
)
4552
created_item = await client.items.create(to_create)
4653

4754
print(dict(created_item))
4855

56+
# Fetch a totp code from the item
57+
for f in created_item.fields:
58+
if f.field_type == "Totp":
59+
if f.details.content.error_message is not None:
60+
print(f.details.content.error_message)
61+
else:
62+
print(f.details.content.code)
63+
64+
4965
# Retrieve an item from your vault.
5066
item = await client.items.get(created_item.vault_id, created_item.id)
5167

0 commit comments

Comments
 (0)