@@ -0,0 +1,1367 @@
+from flask import Flask, redirect, url_for, session, request%0Afrom flask_oauthlib.client import OAuth, facebook_urls%0A%0A%0AFACEBOOK_APP_ID = '188477911223606'%0AFACEBOOK_APP_SECRET = '621413ddea2bcc5b2e83d42fc40495de'%0A%0A%0Aapp = Flask(__name__)%0Aapp.debug = True%0Aapp.secret_key = 'development'%0Aoauth = OAuth()%0A%0Afacebook = oauth.remote_app(%0A    'facebook',%0A    consumer_key=FACEBOOK_APP_ID,%0A    consumer_secret=FACEBOOK_APP_SECRET,%0A    request_token_params=%7B'scope': 'email'%7D,%0A    **facebook_urls%0A)%0A%0A%0A@app.route('/')%0Adef index():%0A    return redirect(url_for('login'))%0A%0A%0A@app.route('/login')%0Adef login():%0A    return facebook.authorize(callback=url_for('facebook_authorized',%0A        next=request.args.get('next') or request.referrer or None,%0A        _external=True))%0A%0A%0A@app.route('/login/authorized')%0A@facebook.authorized_handler%0Adef facebook_authorized(resp):%0A    if resp is None:%0A        return 'Access denied: reason=%25s error=%25s' %25 (%0A            request.args%5B'error_reason'%5D,%0A            request.args%5B'error_description'%5D%0A        )%0A    session%5B'oauth_token'%5D = (resp%5B'access_token'%5D, '')%0A    me = facebook.get('/me')%0A    return 'Logged in as id=%25s name=%25s redirect=%25s' %25 %5C%0A        (me.data%5B'id'%5D, me.data%5B'name'%5D, request.args.get('next'))%0A%0A%0A@facebook.tokengetter%0Adef get_facebook_oauth_token():%0A    return session.get('oauth_token')%0A%0A%0Aif __name__ == '__main__':%0A    app.run()%0A

copy facebook example from flask-oauth