def ensure_login(ctx):
logger = logging.getLogger(__name__)<EOL>logger.info('<STR_LIT>', __name__)<EOL>if ctx.obj['<STR_LIT>'] is None:<EOL><INDENT>if ctx.obj['<STR_LIT:username>'] is None or ctx.obj['<STR_LIT:password>'] is None:<EOL><INDENT>raise click.UsageError(<EOL>'<STR_LIT>'<EOL>'<STR_LIT>')<EOL>sys.exit(<NUM_LIT:1>)<EOL><DEDENT>logger.debug(<EOL>'<STR_LIT>',<EOL>ctx.obj['<STR_LIT:username>'],<EOL>ctx.obj['<STR_LIT>'])<EOL>token = get_keeper_token(<EOL>ctx.obj['<STR_LIT>'],<EOL>ctx.obj['<STR_LIT:username>'],<EOL>ctx.obj['<STR_LIT:password>'])<EOL>ctx.obj['<STR_LIT>'] = token<EOL>logger.debug(<EOL>'<STR_LIT>',<EOL>ctx.obj['<STR_LIT:username>'],<EOL>ctx.obj['<STR_LIT>'])<EOL><DEDENT>else:<EOL><INDENT>logger.debug(<EOL>'<STR_LIT>')<EOL><DEDENT>
Ensure a token is in the Click context object or authenticate and obtain
    the token from LTD Keeper.

    Parameters
    ----------
    ctx : `click.Context`
        The Click context. ``ctx.obj`` must be a `dict` that contains keys:
        ``keeper_hostname``, ``username``, ``password``, ``token``. This
        context object is prepared by the main Click group,
        `ltdconveyor.cli.main.main`.