Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Apprendre Flask-JWT-Extended Set Up | Authentication with JWT
Professional Web API with Flask

bookFlask-JWT-Extended Set Up

To integrate the authentication feature into our website, we will use the Flask-JWT-Extended library. First, let's install it by running the following command:

Code Setup and Configuration

Next, in the app.py file, we import JWTManager from the flask_jwt_extended library:

We then add another configuration parameter within our create_app() function:

Just as we secured our SECRET_KEY in the .env file, we will also hide the JWT key. It's best to use a random set of values for greater security, similar to how we generated the SECRET_KEY.

Initialization

After adding the necessary information to the .env and .env.sample files, we initialize the jwt variable using the JWTManager and pass our app to it:

In the next chapter, we will write an endpoint for user registration.

question mark

What is the primary purpose of using Flask-JWT-Extended in a Flask application?

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 5. Chapitre 2

Demandez à l'IA

expand

Demandez à l'IA

ChatGPT

Posez n'importe quelle question ou essayez l'une des questions suggérées pour commencer notre discussion

Awesome!

Completion rate improved to 3.03

bookFlask-JWT-Extended Set Up

Glissez pour afficher le menu

To integrate the authentication feature into our website, we will use the Flask-JWT-Extended library. First, let's install it by running the following command:

Code Setup and Configuration

Next, in the app.py file, we import JWTManager from the flask_jwt_extended library:

We then add another configuration parameter within our create_app() function:

Just as we secured our SECRET_KEY in the .env file, we will also hide the JWT key. It's best to use a random set of values for greater security, similar to how we generated the SECRET_KEY.

Initialization

After adding the necessary information to the .env and .env.sample files, we initialize the jwt variable using the JWTManager and pass our app to it:

In the next chapter, we will write an endpoint for user registration.

question mark

What is the primary purpose of using Flask-JWT-Extended in a Flask application?

Select the correct answer

Tout était clair ?

Comment pouvons-nous l'améliorer ?

Merci pour vos commentaires !

Section 5. Chapitre 2
some-alt