python - Is there a way to manage authentication for web services with Flask? -


i trying use flask in order provide http based web-services android application. have found flask-login easiest way manage authentication seems oriented template based web application.

is there solution web-service based authentication?

flask-login solution. can add next decorator views:

def login_required():     def wrapper(fn):         @wraps(fn)         def decorated_view(*args, **kwargs):             if not current_user.is_authenticated():                 abort(401)                 # return jsonify(status='logged_off')             return fn(*args, **kwargs)         return decorated_view     return wrapper 

so if user don't authorized view login_required decorator return 401 unauthorized response (or valid response custom message if want).


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -