def generate_token(user_id, expire_in=None, data={}, issuer=None, iat=None):
assert user_id, "<STR_LIT>"<EOL>assert isinstance(data, dict), "<STR_LIT>"<EOL>assert get_config().jwt_secret, "<STR_LIT>"<EOL>if not issuer:<EOL><INDENT>issuer = get_config().jwt_issuer<EOL><DEDENT>assert issuer, "<STR_LIT>"<EOL>if expire_in is None:<EOL><INDENT>expire_in = get_config().jwt_token_timeout<EOL><DEDENT>if iat:<EOL><INDENT>epoch_now = iat<EOL><DEDENT>else:<EOL><INDENT>epoch_now = to_epoch(timenow())<EOL><DEDENT>epoch_end = epoch_now + expire_in<EOL>data['<STR_LIT>'] = issuer<EOL>data['<STR_LIT>'] = user_id<EOL>data['<STR_LIT>'] = get_config().jwt_audience<EOL>data['<STR_LIT>'] = epoch_end<EOL>data['<STR_LIT>'] = epoch_now<EOL>headers = {<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": "<STR_LIT>",<EOL>"<STR_LIT>": issuer,<EOL>}<EOL>log.debug("<STR_LIT>" % (data, headers, get_config().jwt_secret[<NUM_LIT:0>:<NUM_LIT:8>]))<EOL>t = jwt.encode(<EOL>data,<EOL>get_config().jwt_secret,<EOL>headers=headers,<EOL>)<EOL>if type(t) is bytes:<EOL><INDENT>t = t.decode("<STR_LIT:utf-8>")<EOL><DEDENT>return t<EOL>
Generate a new JWT token for this user_id. Default expiration date
    is 1 year from creation time