Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/347.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 烧瓶JWT和x27的Apidoc;s身份验证url_Python_Api Doc_Flask Jwt - Fatal编程技术网

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的请求中获得的请求数据是
    '
    (空)
  • 即使在docstring中包含
    内容类型
    标题,它也会失败。我在flask的请求中得到的请求数据是
    username=test@example.com&密码=test123
  • 我已经在Flask JWT的代码中添加了调试点,从而确认了上述内容

    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标头

    我错过了什么