Authenticate users with AWS Cognito
Project description
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_COGNITO_USER_POOL_ID'] = 'eu-west-1_Drvd8r4TM'
app.config['AWS_COGNITO_USER_POOL_CLIENT_ID'] = '545isk1een1lvilb9en643g3vd'
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
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)
ToDo
- token refresh
- client credentials flow for machine-to-machine interactions
- create user pool client with secret (token endpoint will need a header)
- logout
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.0.tar.gz
(533.8 kB
view hashes)
Built Distribution
Close
Hashes for Flask_AWSCognito-1.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 266a923e078171c7c6e4df2b6184e4bb85bb7fa566dc472ed78f0b5c97c8c3bb |
|
MD5 | e8c8dac5adf1e2ed307b855e2dbd8cac |
|
BLAKE2b-256 | 2e8d00f9ac17c962bca9ef8d5f1e3e206b7869e64e93101ad1dcc808dfde1950 |