def generate(alg):
key = priv_keys[alg].get('<STR_LIT:default>', priv_key)<EOL>def f(claims, alg, lifetime=None, expires=None, not_before=None):<EOL><INDENT>"""<STR_LIT>"""<EOL>now = datetime.utcnow()<EOL>return spawn(<EOL>"<STR_LIT>".format(<EOL>now=timegm(now.utctimetuple()),<EOL>header=json_encode({'<STR_LIT>': alg}),<EOL>claims=json_encode(claims),<EOL>expires=timegm(((now + lifetime) if lifetime else expires).utctimetuple()),<EOL>not_before=timegm((not_before or now).utctimetuple()),<EOL>key=json_encode(base64url_decode(json_decode(key.export())['<STR_LIT:k>']) if key.is_symmetric else key.export_to_pem(True, None))),<EOL>False)<EOL><DEDENT>return f<EOL>
return function which can generate token using node-jsjws