使用OAuth2保护Flask-Restful API [英] Securing Flask-Restful API with OAuth2
本文介绍了使用OAuth2保护Flask-Restful API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
好的,所以我用Flask-Restful编写了一个API,现在我想实现OAuth2授权.
Okay, so I wrote an API using Flask-Restful and now I want to implement OAuth2 authorization.
我已经尝试过 pyoauth2 ,但是它没有文档说明,并且
I've tried pyoauth2, but it's undocumented and the tutorial is quite complicated.
所以,我的问题是:我该怎么做?
So, my question is: How do I do that?
推荐答案
-
按照flask-oauthlib指南进行基本端点设置.确保它与香草烧瓶终点配合使用.
Follow the flask-oauthlib guide to get a basic endpoint set up. Ensure that it works with a vanilla flask endpoint.
配置您的API以使用oauth装饰器.
Configure your API to use the oauth decorator.
oauth = OAuth2Provider(app)
api = restful.Api(app, decorators=[oauth.require_oauth('email')])
这篇关于使用OAuth2保护Flask-Restful API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文