def factory(ec, code=None, token=None, refresh=None, **kwargs):
    """
    Create a token handler

    :param code:
    :param token:
    :param refresh:
    :return: TokenHandler instance
    """

    TTYPE = {'code': 'A', 'token': 'T', 'refresh': 'R'}

    args = {}

    if code:
        args['code_handler'] = init_token_handler(ec, code, TTYPE['code'])
    if token:
        args['access_token_handler'] = init_token_handler(ec, token, TTYPE['token'])
    if refresh:
        args['refresh_token_handler'] = init_token_handler(ec, token, TTYPE['refresh'])

    return TokenHandler(**args)
Create a token handler

    :param code:
    :param token:
    :param refresh:
    :return: TokenHandler instance