Search⌘ K
AI Features

Necessary Changes for Creating the Authentication API

Explore how to create a secure authentication API with Flask by implementing password hashing, managing user registration and login, issuing JWT access tokens, and protecting routes. Understand the full authentication flow including token testing and user record deletion to build safer web applications.

The authentication API is where the various pieces come together. First, we’ll use password hashing to create authentication records and verify credentials. Second, we’ll provide the means by which a user can authenticate and receive their access token. Third, we’ll show an example of how to modify a route to make it require a valid access token.

Imports

The imports are mostly familiar. The new ones are auth_orm, which we just created in the previous lesson, and flask_jwt_extended, which makes it easy to work with JWT access tokens. To install it, we use pipenv. We’ll notice, however, that it’s installed using hyphens between the words but imported using underscores.

$ pipenv install flask-jwt-extended

To create the API, we’ll need the usual imports, and also our new ...