Flask-JWT or Flask-Login

3.4k views Asked by At

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

There are 1 answers

2
s3bw On

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.