Facebook Connect for Flask
Asked Answered
H

2

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.

Homophonic answered 30/3, 2011 at 13:37 Comment(2)
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.Wildermuth
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.Homophonic
F
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

Flatfooted answered 27/12, 2011 at 21:34 Comment(1)
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.Extremist
T
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.

Tetrapody answered 5/6, 2012 at 13:19 Comment(1)
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).Slighting

© 2022 - 2024 — McMap. All rights reserved.