Skip to main content

Authenticate users with AWS Cognito

Project description

Build Status Documentation Status

AWS Cognito for authentication in Flask

Documentation https://flask-awscognito.readthedocs.io

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'] = 'domain.com'
app.config['AWS_COGNITO_USER_POOL_ID'] = 'eu-west-1_XXX'
app.config['AWS_COGNITO_USER_POOL_CLIENT_ID'] = 'YYY'
app.config['AWS_COGNITO_USER_POOL_CLIENT_SECRET'] = 'ZZZZ'
app.config['AWS_COGNITO_REDIRECT_URL'] = 'http://localhost:5000/aws_cognito_redirect'


aws_auth = AWSCognitoAuthentication(app)


@app.route('/')
@aws_auth.authentication_required
def index():
    claims = aws_auth.claims # also available through g.cognito_claims
    return jsonify({'claims': claims})


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


@app.route('/sign_in')
def sign_in():
    return redirect(aws_auth.get_sign_in_url())


if __name__ == '__main__':
    app.run(debug=True)

Project details


Download files

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

Source Distribution

Flask-AWSCognito-1.3.tar.gz (537.5 kB view details)

Uploaded Source

Built Distribution

Flask_AWSCognito-1.3-py3-none-any.whl (12.4 kB view details)

Uploaded Python 3

File details

Details for the file Flask-AWSCognito-1.3.tar.gz.

File metadata

  • Download URL: Flask-AWSCognito-1.3.tar.gz
  • Upload date:
  • Size: 537.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for Flask-AWSCognito-1.3.tar.gz
Algorithm Hash digest
SHA256 9ed4560cbb6ecb07bd121a38b0aec560007cb4e02f08c5f57ae895b955fe3502
MD5 5ee44da72a01202821f041fc66fb6464
BLAKE2b-256 0e5c43070167d07b4c49c8497f774f2e5083dacb2b654a3d93313852c66cec6d

See more details on using hashes here.

File details

Details for the file Flask_AWSCognito-1.3-py3-none-any.whl.

File metadata

  • Download URL: Flask_AWSCognito-1.3-py3-none-any.whl
  • Upload date:
  • Size: 12.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.36.1 CPython/3.6.8

File hashes

Hashes for Flask_AWSCognito-1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 cb031758b65ae062e0dc7867cf8689f24ea1477a3a48f7e274b0dbee7b829f82
MD5 86d338d7dd5715f3b11291d6ac2d5f62
BLAKE2b-256 5b979e9e105e79ec74b237cbb2fb26d1fd62e10f489677d99e68269d98d3d991

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page