Facebook Logout on Chrome Extension

2019-05-26 14:30发布

问题:

I have a chrome extension that uses the facebook Graph API

Because its a Chrome extension I was using the Native App flow to login. I used content-scripts to grab the token out of the redirect URL.

However, I'm unable to find a way to logout of facebook. I tried the logout method posted here: Facebook Oauth Logout , but it doesn't seem to work ( I used my App Id as the API key and the "code" parameter returned by the redirect as the session key )

Does anyone know of a way to do this?

回答1:

So, after tracing the SDK logout procedure I found it just deletes the users Cookies for Facebook. Specifically this chunk of code will log the user out in a chrome extension (requires cookie permission):

var facebookDomain = "http://www.facebook.com";
chrome.cookies.remove ( {"url": facebookDomain, "name": "act" } );
chrome.cookies.remove ( {"url": facebookDomain, "name": "c_user" } );
chrome.cookies.remove ( {"url": facebookDomain, "name": "checkpoint" } );
chrome.cookies.remove ( {"url": facebookDomain, "name": "lu" } );
chrome.cookies.remove ( {"url": facebookDomain, "name": "s" } );
chrome.cookies.remove ( {"url": facebookDomain, "name": "sct" } );
chrome.cookies.remove ( {"url": facebookDomain, "name": "xs" } );