Question

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?

Was it helpful?

Solution

  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')])
    
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top