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响应之外,我还应该返回什么?
P.S。我尝试从函数中删除identity
参数-它完全不会改变任何内容。
答案 0 :(得分:1)
该库已经有5年不受支持了,因此我使用了Flask-JWT-Extended
。可能可以解决原始问题,但是我认为这没有道理。