Skip to main content

Authenticate users with AWS Cognito

Project description

Build Status Documentation Status

AWS Cognito for authentication in Flask


Example App

from flask import Flask, redirect, request, jsonify
from flask_awscognito import AWSCognitoAuthentication
app = Flask(__name__)

app.config['AWS_DEFAULT_REGION'] = 'eu-west-1'
app.config['AWS_COGNITO_DOMAIN'] = ''
app.config['AWS_COGNITO_USER_POOL_ID'] = 'eu-west-1_XXX'
app.config['AWS_COGNITO_REDIRECT_URL'] = 'http://localhost:5000/aws_cognito_redirect'

aws_auth = AWSCognitoAuthentication(app)

def index():
    claims = # also available through g.cognito_claims
    return jsonify({'claims': claims})

def aws_cognito_redirect():
    access_token = aws_auth.get_access_token(request.args)
    return jsonify({'access_token': access_token})

def sign_in():
    return redirect(aws_auth.get_sign_in_url())

if __name__ == '__main__':

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for Flask-AWSCognito, version 1.3
Filename, size File type Python version Upload date Hashes
Filename, size Flask_AWSCognito-1.3-py3-none-any.whl (12.4 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size Flask-AWSCognito-1.3.tar.gz (537.5 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page