0
votes

I am trying to build a Flask backend with REST but I am unsure to use Flask-JWT or Flask-Login for managing user logins and authorization. I thought of using it both. Can I do so? If I can, then should I use @jwt_required() or **@login_required decorator?

1
NOTE for newcomers: use instead, the Flask-JWT-Extended, which is found flask-jwt-extended.readthedocs.io/en/stable, has been updated more recently and has better documentation.Alexey Nikonov

1 Answers

2
votes

Have a look at the flask-jwt-extended package. It comes with very handy basic and advanced examples for using JSON Webtokens. The example I've linked uses a single decorator jwt_required.

And if you require re-authentication, there's an example using a refresh_token. https://flask-jwt-extended.readthedocs.io/en/stable/token_freshness/

Be sure to read up on website authentication. Here's a good place to start:

But try keep it simple to start.