Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/cgauge/flask-awscognito
Extension for Flask that adds support for AWSCognito into your application
https://github.com/cgauge/flask-awscognito
aws-cognito flask python
Last synced: about 2 months ago
JSON representation
Extension for Flask that adds support for AWSCognito into your application
- Host: GitHub
- URL: https://github.com/cgauge/flask-awscognito
- Owner: cgauge
- License: mit
- Created: 2019-09-20T12:56:01.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-04-29T21:00:47.000Z (over 3 years ago)
- Last Synced: 2024-04-25T14:40:23.902Z (8 months ago)
- Topics: aws-cognito, flask, python
- Language: Python
- Homepage: https://flask-awscognito.readthedocs.io
- Size: 384 KB
- Stars: 28
- Watchers: 6
- Forks: 27
- Open Issues: 11
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Build Status](https://travis-ci.org/cgauge/Flask-AWSCognito.svg?branch=master)](https://travis-ci.org/cgauge/Flask-AWSCognito)
[![Documentation Status](https://readthedocs.org/projects/flask-awscognito/badge/?version=latest)](https://flask-awscognito.readthedocs.io/en/latest/?badge=latest)# AWS Cognito for authentication in Flask
Documentation https://flask-awscognito.readthedocs.io
## Maintainer(s) Needed
This project is in search for new maintainer(s). Please see [Issue #13](https://github.com/cgauge/Flask-AWSCognito/issues/13) for details.
## Example App
```python
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)```