app-engine-patch and pyFacebook not working

给你一囗甜甜゛ 提交于 2019-11-30 22:44:00

You should not use pyfacebook's decorator @facebook.require_login() when using pyfacebook with facebook-connect. The decorator is meant to be used for a facebook application, as it redirects the user to the facebook site if they are not logged in, but you really want to redirect the user to your login page on your site if they are not logged in.

To check if someone is logged in with facebook-connect and pyfacebook with the djangofb middleware, you call request.fb.check_session(request). If check_session returns True then they have a valid session. If it returns False then you need to redirect the user to your login page so they can click the facebook connect login button you (should) have placed on that page.

If you change facebook/__init__.py line 1292+ from this:

    if params.get('expires'):
        self.session_key_expires = int(params['expires'])

To this:

    if params.get('expires'):
        if params['expires'] == 'None':
            params['expires'] = 0   
        self.session_key_expires = int(params['expires'])

It will work, but it is a hack and maybe it could be done more elegantly, but it works.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!