Securing Flask-Restful API with OAuth2

本小妞迷上赌 提交于 2020-07-31 13:30:29

问题


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:


  1. Follow the flask-oauthlib guide to get a basic endpoint set up. Ensure that it works with a vanilla flask endpoint.

  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!