Skip to main content
BackAnt ships a token_required decorator in api/decorators/token_required.py that validates the Authorization: Bearer <token> header on incoming requests.

The token_required decorator

Protecting a route

Apply @token_required as a decorator on the route function:
Requests without a valid Authorization header return:

JWT validation

The default decorator has a placeholder for token validation. To validate JWTs, add your decoding logic in the try block:

AWS Cognito authentication

The Environment class includes all necessary Cognito variables for validating Cognito JWTs:
Use the flask-Cognito package (included in requirements.txt) to validate Cognito tokens inside token_required.

Making authenticated requests