使用AWS Cognito验证用户

Flask-AWSCognito的Python项目详细描述


Build StatusDocumentation Status

用于烧瓶认证的AWS Cognito

文档https://flask-awscognito.readthedocs.io

示例应用程序

fromflaskimportFlask,redirect,request,jsonifyfromflask_awscognitoimportAWSCognitoAuthenticationapp=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_requireddefindex():claims=aws_auth.claims# also available through g.cognito_claimsreturnjsonify({'claims':claims})@app.route('/aws_cognito_redirect')defaws_cognito_redirect():access_token=aws_auth.get_access_token(request.args)returnjsonify({'access_token':access_token})@app.route('/sign_in')defsign_in():returnredirect(aws_auth.get_sign_in_url())if__name__=='__main__':app.run(debug=True)

欢迎加入QQ群-->: 979659372 Python中文网_新手群

推荐PyPI第三方库


热门话题
ArrayList Java中的搜索字符串   另一个web应用程序的java访问会话   另一个应用程序中的活动和服务之间的java通信   java根据Json字符串类型将Json字符串转换为对象   eclipse如何解决java中的错误异常。lang.NoSuchMethodError:'java。字符串javax。摆动JOptionPane。showInputDialog(java.lang.String)'   线程“main”java中的安卓异常。lang.NoClassDefFoundError:org/codehaus/jackson/JsonParseException   java如何在安卓 emulator上显示Mat图像?使用NDK   Java在本地读取测试源文件,但在服务器上读取失败   java dowhile循环用于计算输入数字中的数字。故障排除代码   JAva初学者在编写获取成本的方法时遇到困难   java是shell游戏。我如何让物体移动,特别是在特定的曲线上,但顺序是随机的?   java如何区分两个同名的JButton   java为什么我在Spring Boot中需要一个接口?   java将文件路径插入数据库将删除\   使用InterfaceType初始化java对象   java如何部署一个分为Angular、Spring Boot和MySQL的项目?   java如何使用Symja解决不等式?