问题
Okay, so I wrote an API using Flask-Restful and now I want to implement OAuth2 authorization.
I've tried pyoauth2, but it's undocumented and the tutorial is quite complicated.
So, my question is: How do I do that?
回答1:
Follow the flask-oauthlib guide to get a basic endpoint set up. Ensure that it works with a vanilla flask endpoint.
Configure your API to use the oauth decorator.
oauth = OAuth2Provider(app) api = restful.Api(app, decorators=[oauth.require_oauth('email')])
来源:https://stackoverflow.com/questions/19875211/securing-flask-restful-api-with-oauth2