Flask-JWT本身可以工作,但我需要向http响应中添加一些值,我尝试这样做:
@jwt.auth_response_callback
def custom_auth_response_handler(access_token, identity):
response = Response({
'accessToken': access_token.decode('utf-8')
})
response.headers['Access-Control-Allow-Origin'] = '*'
return response一旦我添加了这段代码,我就会在启动Flask时出现错误:
Traceback (most recent call last):
File "wsgi.py", line 1, in <module>
from app import create_app
File "D:\Dev\api-general\app\__init__.py", line 40, in <module>
def customized_response_handler(access_token, identity):
TypeError: _default_auth_response_handler() missing 1 required positional argument: 'identity'正如我所说的,没有这些代码,一切都可以正常工作。看起来函数应该为装饰器返回一些东西,但是除了HTTP响应之外,我还应该返回什么呢?
附言:我试着从函数中删除identity参数--这根本不会改变任何事情。
发布于 2020-10-19 20:47:14
这个库已经有5年没有被支持了,所以我使用了Flask-JWT-Extended。可能会有解决原始问题的方法,但我不认为这是合理的。
https://stackoverflow.com/questions/64423956
复制相似问题