python - Facebook login with flask-oauthlib not logging in -
i using flask-aouthlib , following code (import , secret key lines omitted) try implement facebook login. on website have link goes domain.com/login, gets redirected nginx script.
app = flask(__name__) app.debug = true app.secret_key = 'development' oauth = oauth(app) facebook = oauth.remote_app( 'facebook', consumer_key=facebook_app_id, consumer_secret=facebook_app_secret, request_token_params={'scope': 'email'}, base_url='https://graph.facebook.com', request_token_url=none, access_token_url='/oauth/access_token', access_token_method='get', authorize_url='https://www.facebook.com/dialog/oauth' ) @app.route('/') def index(): return redirect(url_for('login')) @app.route('/login') def login(): callback = url_for( 'facebook_authorized', next=request.args.get('next') or request.referrer or none, _external=true ) return facebook.authorize(callback=callback) @app.route('/login/authorized') def facebook_authorized(): resp = facebook.authorized_response() if resp none: return 'access denied: reason=%s error=%s' % ( request.args['error_reason'], request.args['error_description'] ) if isinstance(resp, oauthexception): return 'access denied: %s' % resp.message session['oauth_token'] = (resp['access_token'], '') me = facebook.get('/me') return 'logged in id=%s name=%s redirect=%s' % \ (me.data['id'], me.data['name'], request.args.get('next')) @facebook.tokengetter def get_facebook_oauth_token(): return session.get('oauth_token') if __name__ == '__main__': app.run(host='127.0.0.1',port=8080)
however happens website redirects facebook , displaces error:
not logged in: not logged in. please login , try again.
it never display facebook login form. if logged in, redirects correctly though.
how display login form?
Comments
Post a Comment