def init_app(self, app):
for k, v in CONFIG_DEFAULTS.items():
app.config.setdefault(k, v)
auth_url_rule = app.config.get('JWT_AUTH_URL_RULE', None)
if auth_url_rule:
if self.auth_request_callback == _default_auth_request_handler:
msg = ("an authentication_handler function must be defined "
"when using the built in authentication resource")
assert self.authentication_callback is not None, (msg)
auth_url_options = app.config.get('JWT_AUTH_URL_OPTIONS',
{'methods': ['POST']})
auth_url_options.setdefault('view_func',
self.auth_request_callback)
app.add_url_rule(auth_url_rule, **auth_url_options)
app.errorhandler(JWTError)(self._jwt_error_callback)
if not hasattr(app, 'extensions'): # pragma: no cover
app.extensions = {}
app.extensions['jwt'] = self
评论列表
文章目录