Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Securing Flask-Restful API with OAuth2

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?

like image 429
Ale Avatar asked Nov 09 '13 11:11

Ale


1 Answers

  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')])
    
like image 110
samuraisam Avatar answered Sep 17 '22 14:09

samuraisam