Skip to content
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

recordv3.RecordAddCommand can't add OTP code #1053

Open
Luke-Williams9 opened this issue Jun 29, 2023 · 1 comment
Open

recordv3.RecordAddCommand can't add OTP code #1053

Luke-Williams9 opened this issue Jun 29, 2023 · 1 comment

Comments

@Luke-Williams9
Copy link

Luke-Williams9 commented Jun 29, 2023

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}')
@sk-keeper
Copy link
Collaborator

sk-keeper commented Jun 29, 2023

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
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants