Home > OS >  Get http in Flask
Get http in Flask

Time:02-14

I am starter to python and using Python Flask and generating REST API service.

I want to check authorization header which is sent the client.

But I can't find way to get HTTP header in flask.

Any help for getting HTTP header authorization is appreciated.

CodePudding user response:

If we are talking about using basic HTTP Auth then you can get the username and password with Flask like this:

from flask import request

@app.route('/route')
def route():
    username = request.authorization.username
    password = request.authorization.password
    ...

Be advised: there are some security concerns when using basic HTTP Auth

CodePudding user response:

Please consider using JWT tokens for authentication.

A flask library to implement this paradigm is: fkask_restful

  • Related