-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I still get otpauth://totp/Whatever:user?secret=xxx
instead of actual OTP values
#99
Comments
You can get the OTP code from the item with item.get() method, as shown in example code:
|
for those newbies:
find out vault id via listing all vaultshttps://developer.1password.com/docs/sdks/list-vaults-items#list-vaults # Gets all vaults in an account.
vaults = await client.vaults.list_all()
async for vault in vaults:
print(vault.id) find out item id via listing all items inside the chosen vaulthttps://developer.1password.com/docs/sdks/list-vaults-items#list-items # Gets all items in a vault.
items = await client.items.list_all(vault_id)
async for item in items:
print(item.id) fetch the item by vault id and item idhttps://developer.1password.com/docs/sdks/manage-items#get-an-item # Gets an item.
item = await client.items.get(created_item.vault_id, created_item.id)
print(dict(item)) list all itemfields of a specific item and use field_type to identify the totphttps://developer.1password.com/docs/sdks/manage-items#get-a-one-time-password # Retrieves a one-time password from an item.
for f in created_item.fields:
if f.fieldType == "Totp":
if f.details.content.error_message is not None:
print(f.details.content.error_message)
else:
print(f.details.content.code) How I put everything togetherdo things step by step oterhwise is not possible. because it's hard to know the id from the 1password app unlike secret reference. # step 1
vaults = await client.vaults.list_all()
async for vault in vaults:
print(vault.id)
print(vault.title)
# step 2 save the id after printing all the vaults
vault_id = "VAULTID" # for title='VAULT TITLE'
# step 3 show all items of the vault
items = await client.items.list_all(vault_id)
async for item in items:
print(item.id)
print(item)
# step 4 save the item id
item_id = "ITEMID" # for title = 'ITEM TITLE'
# step 5 get the item by vault and item id and then print the code
the_item_with_totp = await client.items.get(vault_id, item_id)
print(dict(the_item_with_totp))
# Fetch a totp code from the item
for f in the_item_with_totp.fields:
if f.field_type == "Totp":
if f.details.content.error_message is not None:
print(f.details.content.error_message)
else:
print(f.details.content.code) |
Originally posted by @MOmarMiraj in #59 (comment)
I am now using
git+ssh://git@github.com/1Password/onepassword-sdk-python.git@v0.1.0-beta.12
and sadly I am still getting back OTP info as a otpauth string instead of the actual OTP values which is a 6 digit number that changes devery 30 seconds or soThe text was updated successfully, but these errors were encountered: