9

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?

Ale
  • 1,998
  • 19
  • 31
  • 1
    Update: I'm currently using [Flask-OAuthlib](https://flask-oauthlib.readthedocs.org/), but it doesn't play well with Flask-Restful, so I had to port my entire API to vanilla Flask (luckily it wasn't that big). Maybe there is a way, though -- looking into this. – Ale Jan 15 '14 at 17:41

1 Answers1

7
  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')])
    
samuraisam
  • 1,927
  • 1
  • 20
  • 24