21

With Flask-OpenID there's a really nice OpenID module for the Flask framework. However, facebook only supports FBconnect and no real OpenID.

I'm looking for a modified version of Flask-OpenID (if one exists) which supports FBconnect or a library doing FBconnect authentication in a similar way as Flask-OpenID.

Jon Parise
  • 1,373
  • 14
  • 14
ThiefMaster
  • 310,957
  • 84
  • 592
  • 636
  • Can't even flag this one. A diamond mod asking an off-topic question: `Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam.` – devnull Dec 16 '13 at 08:04
  • Heh, I wasn't a mod yet when asking it! Anyway, feel free to CV it - I don't think there's much need for further answers. – ThiefMaster Dec 16 '13 at 11:49

2 Answers2

37

The Flask-OAuth extension supports Facebook authentication:

facebook = oauth.remote_app('facebook',
    base_url='https://graph.facebook.com/',
    request_token_url=None,
    access_token_url='/oauth/access_token',
    authorize_url='https://www.facebook.com/dialog/oauth',
    consumer_key=FACEBOOK_APP_ID,
    consumer_secret=FACEBOOK_APP_SECRET,
    request_token_params={'scope': 'email'}
)

Here's a full Facebook example: https://github.com/mitsuhiko/flask-oauth/blob/master/example/facebook.py

Jon Parise
  • 1,373
  • 14
  • 14
  • The original Flask-OAuth suffers from lack of maintenance, and oauthlib is a promising replacement for python-oauth2. Flask-OAuthlib is designed to be a replacement for Flask-OAuth. It depends on oauthlib. – Hieu Dec 01 '16 at 11:55
6

You might also want to checkout Flask-Social as well (which is an extension on top of Flask-Security). I'm in the middle of setting it up myself, but so far no issues. Flask-Security, if you're not familiar, combines Flask-Login, Flask-Principal, and a few other extensions for a quick security layer, and Flask-Social adds the OAuth features.

Sean Lynch
  • 6,267
  • 2
  • 43
  • 45
  • So for an app where I want users to be able to login via Facebook or Twitter, & then set different roles etc, these two extensions (and their dependencies) are still (two years later) the go-to out-of-the-box solutions? They don't seem to be covered in the recent Flask Web Development book by @miguelgrinberg (but I have the early release). – scharfmn Jun 04 '14 at 15:49