Warrant

raw JSON →
0.6.1 verified Fri May 01 auth: no python maintenance

Python class to integrate Boto3's Cognito client so it is easy to login users. With SRP support. Current version: 0.6.1. Release cadence is irregular; no longer actively maintained.

pip install warrant
error AttributeError: module 'warrant' has no attribute 'Cognito'
cause Import path changed; using wrong import statement.
fix
Use 'from warrant import Cognito' instead of 'import warrant; warrant.Cognito'.
error botocore.exceptions.NoRegionError: You must specify a region.
cause The pool_region parameter was not passed and AWS region is not set via environment.
fix
Pass pool_region='your-region' to Cognito constructor or set AWS_DEFAULT_REGION environment variable.
error KeyError: 'IdToken'
cause Trying to access id_token before authentication is complete.
fix
Call u.authenticate() first, then u.id_token is available.
deprecated Warrant 0.6.1 is the last release; the project is in maintenance mode with no active development. Consider using python-cognito or direct boto3/cognitoidp calls for new projects.
fix Migrate to python-cognito (pip install python-cognito) or use boto3.client('cognitoidp').
gotcha The 'pool_region' parameter is required when instantiating Cognito if the default region is not set via AWS environment variables. Omitting it may lead to region-related errors.
fix Always pass pool_region='us-east-1' (or your region) to Cognito constructor.
breaking In version 0.6.0, the token verification logic changed. Tokens generated with older versions may fail verification after upgrade.
fix Ensure your Cognito user pool app client settings align with the new token verification (e.g., correct access token validation).

Initialize Cognito client with user pool ID and client ID.

import os
from warrant import Cognito

user_pool_id = os.environ.get('USER_POOL_ID', '')
client_id = os.environ.get('CLIENT_ID', '')

if not user_pool_id or not client_id:
    print('Set USER_POOL_ID and CLIENT_ID environment variables')
else:
    u = Cognito(user_pool_id, client_id)
    print('Cognito client created successfully')