Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Login Endpoint | Authentication with JWT
Professional Web API with Flask
course content

Зміст курсу

Professional Web API with Flask

Professional Web API with Flask

1. Introduction to the Course
2. Database and Models
3. Flask-Smorest and Schemas
4. Endpoints with Blueprints and MethodView
5. Authentication with JWT
6. Deployment

book
Login Endpoint

The class and method for login are similar to those for registration. Let's write it:

We filter users in the database by username and check if such a user exists and if the password verification for this user passes. If so, we create a JWT access token.

In this method, we return an access token generated using the create_access_token function imported from the flask_jwt_extended library. We add the user ID information to the JWT access token so that when a user returns the JWT to us, we will know which user it belongs to.

If a user with the given username does not exist or the password does not match what is in the table, we return an error.

1. Which HTTP method is used by the UserLogin class to authenticate users?
2. What information is included in the JWT access token generated by the UserLogin method?
Which HTTP method is used by the UserLogin class to authenticate users?

Which HTTP method is used by the UserLogin class to authenticate users?

Виберіть правильну відповідь

What information is included in the JWT access token generated by the UserLogin method?

What information is included in the JWT access token generated by the UserLogin method?

Виберіть правильну відповідь

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 5. Розділ 4
We're sorry to hear that something went wrong. What happened?
some-alt