Created
October 18, 2011 07:40
-
-
Save pamelafox/1294829 to your computer and use it in GitHub Desktop.
Facebook logout (Flask)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@login_required | |
def handle_logout(): | |
import facebook | |
if g.user.facebook_id: | |
base_domain = util.get_base_domain() | |
default_fb_data = FB_DATA['appspot.com'] | |
fb_app_id = FB_DATA.get(base_domain, default_fb_data).get('appid') | |
fb_app_secret = FB_DATA.get(base_domain, default_fb_data).get('appsecret') | |
cookie = facebook.get_user_from_cookie(request.cookies, fb_app_id, fb_app_secret) | |
if cookie: | |
graph = facebook.GraphAPI(cookie["access_token"]) | |
try: | |
graph.revoke_auth(g.user.facebook_id) | |
except facebook.GraphAPIError, e: | |
logging.info(e) | |
if SESSION_USERID in session: | |
session.pop(SESSION_USERID) | |
return redirect_response(url_for('landing')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment