Python 烧瓶JWT和x27的Apidoc;s身份验证url
我已经开始使用Python 烧瓶JWT和x27的Apidoc;s身份验证url,python,api-doc,flask-jwt,Python,Api Doc,Flask Jwt,我已经开始使用apidoc生成RESTAPI文档。我试过了 在基于flask的api应用程序中,我使用JWT(特别是flask JWT)进行身份验证。文档生成正确,但是来自文档的请求没有正确发生 这就是我用来生成文档的docsting def authenticate(username, password): """ @api {post} /auth Authentication url @apiName Authentication @apiGroup Log
apidoc
生成RESTAPI文档。我试过了
在基于flask
的api应用程序中,我使用JWT
(特别是flask JWT)进行身份验证。文档生成正确,但是来自文档的请求没有正确发生
这就是我用来生成文档的docsting
def authenticate(username, password):
"""
@api {post} /auth Authentication url
@apiName Authentication
@apiGroup Login
@apiParam {String} username Username of the user
@apiParam {String} password Password of the user
@apiSuccess {String} access_code JWT
@apiSuccessExample Success Response
HTTP/1.1 200 OK
{
"access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpZGVudGl0eSI6IjM5MDA4MGExLWY0ZjctMTFlNS04NTRkLTI4ZDI0NDQyZDNlNyIsImlhdCI6MTQ1OTE3ODE0NSwibmJmIjoxNDU5MTc4MTQ1LCJleHAiOjE0NTkxNzg0NDV9.nx_1a4RmvJ7Vlf1CvnMzqoTfzChcuJnDb1Tjy1_FnXw"
}
@apiErrorExample Invalid Credentials
{
"description": "Invalid credentials",
"error": "Bad Request",
"status_code": 401
}
"""
user = session.query(User).filter_by(username=username).first()
if user and user.is_correct_password(password):
return user
return False
当我生成文档时,它被正确地生成了
$ apidoc -i onehop/ -o doc
'
(空)内容类型
标题,它也会失败。我在flask的请求中得到的请求数据是username=test@example.com&密码=test123
def _default_auth_request_handler():
data = request.get_json() # My debug poing
username = data.get(current_app.config.get('JWT_AUTH_USERNAME_KEY'), None)
password = data.get(current_app.config.get('JWT_AUTH_PASSWORD_KEY'), None)
但是,当我使用邮递员发出同样的请求时,它会正确地发生
邮递员头条
Apidoc标头
我错过了什么