Commander
Commander copied to clipboard
recordv3.RecordAddCommand can't add OTP code
RecordAddCommand isn't adding an OTP code, is it possible or should I be looking at import functions instead?
here's my function. I've tried using oneTimeCode as a parameter, as well as passing a custom field "TFC:Keeper" to RecordAddCommand, and neither work.
def add_record(rec):
record_path = ('/' + rootFolder + '/' + rec['client'])
command = RecordAddCommand()
record_uid = command.execute(
connect_params,
type = rec['type'] if 'type' in rec else None,
title = rec['title'] if 'title' in rec else None,
login = rec['login'] if 'login' in rec else None,
oneTimeCode = rec['otp'] if 'otp' in rec else None,
password = rec['password'] if 'password' in rec else None,
url = rec['url'] if 'url' in rec else None,
notes = rec['notes'] if 'notes' in rec else None,
folder = record_path,
custom = rec['custom'] if 'custom' in rec else None,
generate = False if 'password' in rec else True,
force = True,
debug = True
)
print(f'Added record {record_uid} to path {record_path}')
oneTimeCode can be passed as an option parameter:
option=['f.oneTimeCode=otpauth://totp/?secret=DFGFDGFDGFDG']
This command is deprecated.
Commander has another command for adding records record-add or record_edit. RecordAddCommand
https://docs.keeper.io/secrets-manager/commander-cli/command-reference/record-commands#record-add-and-record-update-commands
Command
record-add --record-type=login --title='Record Title' --notes='a\nb\nc\nd' --folder="Folder Name" [email protected] password=$GEN url=https://google.com oneTimeCode=otpauth://totp/?secret=DFGFDGFDGFDG "Custom Field"="Custom Value"
uses the following parser
record_add_parser = argparse.ArgumentParser(prog='record-add', description='Add a record to folder.')
record_add_parser.add_argument('--syntax-help', dest='syntax_help', action='store_true',
help='Display help on field parameters.')
record_add_parser.add_argument('-f', '--force', dest='force', action='store_true', help='ignore warnings')
record_add_parser.add_argument('-t', '--title', dest='title', action='store', help='record title')
record_add_parser.add_argument('-rt', '--record-type', dest='record_type', action='store', help='record type')
record_add_parser.add_argument('-n', '--notes', dest='notes', action='store', help='record notes')
record_add_parser.add_argument('--folder', dest='folder', action='store',
help='folder name or UID to store record')
record_add_parser.add_argument('fields', nargs='*', type=str,
help='load record type data from strings with dot notation')
can be translated to this code
command = record_edit.RecordAddCommand()
record_uid = command.execute(
connect_params,
record_type = 'login',
title = 'Record Title',
notes = 'a\nb\nc\nd',
folder='Folder Name',
fields=['[email protected]', 'password=$GEN',
'url=https://google.com',
'oneTimeCode=otpauth://totp/?secret=DFGFDGFDGFDG',
'"Custom Field"="Custom Value"'],
force = True
)