需要在标头restPlus中传递apikey,用户名,customer_id

时间:2019-06-26 11:12:53

标签: python flask-restplus

我正在尝试在标头中传递apikey,用户名,customer_id,这里可以通过另一种格式进行apikey授权,但是无法在标头中传递用户名,customer_id

@api.header('X-Consumer-Custom-ID')
@api.header('X-Consumer-Username')
class check(Resource):
@login_required
    def post(self):
        parser = reqparse.RequestParser()
        parser.add_argument('id', type=str, location='form', required=True)
        parser.add_argument('X-Consumer-Custom-ID', location='headers')
        parser.add_argument('X-Consumer-Username', location='headers')
        args = parser.parse_args()
        order_id = args['id']

apiKey通过标头中的另一种格式授权:

authorizations = {
    'apikey': {
        'type': 'apiKey',
        'in': 'header',
        'name': 'X-API-KEY'
    }}
app = Flask(__name__)
SWAGGER_DOC = True
api = Api(app, authorizations=authorizations, security=['apikey'], version='dev',
          title='Awesome Flask APIs',
          doc="/" if SWAGGER_DOC is True else False,
          description='Awesome RESTful APIs, written in Flask', )

请帮助我,我想传递三个参数,任何想法或建议都将对我感激

0 个答案:

没有答案