I think I've read just about everything out there on the topic of logging out of Facebook inside of a Desktop application. Nothing so far works.
Specifically, I would like to log the user out so that they can switch identities, e.g. People sharing a computer at home could then use the software with their own Facebook accounts, but with no chance to switch accounts, it's quite messy. (Have not yet tested switching Windows users accounts as that is simply far too much to ask of the end user and should not be necessary.)
Now, I should say that I have set the application to use these permissions:
string[] permissions = new string[] { "user_photos", "publish_stream", "offline_access" };
So, "offline_access" is included there. I do not know if this does/should affect logging out or not.
Again, my purpose for logging out is merely to switch users. (If there's a better approach, please let me know.)
The purported solutions seem to be:
Use the JavaScript SDK (FB.logout())
Use "m.facebook.com" instead
Create your own URL (and possibly use m.facebook.com)
Create your own URL and use the session variable (in ASP.NET)
The first is kind of silly. Why resort to JavaScript when you're using C#? It's kind of a step backwards and has a lot of additional overhead in a desktop application. (I have not tried this as it's simply disgustingly messy to do this in a desktop application.) If anyone can confirm that this is the only working method, please do so. I'm desperately trying to avoid it.
The second doesn't work. Perhaps it worked in the past, but my umpteen attempts to get it to work have all failed.
The third doesn't work. I've tried umpteen dozen variations with zero success.
The last option there doesn't work for a desktop application because it's not ASP.NET and you don't have a session variable to work with.
The Facebook C# SDK logout also no longer works. i.e.
public FacebookLoginDialog(string appId, string[] extendedPermissions, bool logout)
{
IDictionary<string, object> loginParameters = new Dictionary<string, object>
{
{ "response_type", "token" },
{ "display", "popup" }
};
_navigateUri = FacebookOAuthClient.GetLoginUrl(appId, null, extendedPermissions, logout, loginParameters);
InitializeComponent();
}
I remember it working in the past, but it no longer works now. (Which truly puzzles me...)
It instead now directs the user to the Facebook mobile page, where the user must manually logout.
Now, I could do browser automation to automatically click the logout link for the user, however, this is prone to breaking if Facebook updates the mobile UI. It is also messy, and possibly a worse solution than trying to use the JavaScript SDK FB.logout() method (though not by much).
I have searched for some kind of documentation, however, I cannot find anything in the Facebook developer documentation that illustrates how to logout an application.
Has anyone solved this problem, or seen any documentation that can be ported to work with the Facebook C# SDK?
I am certainly open to using a WebClient or HttpClient/Response if anyone can point to some documentation that could work with it. I simply have not been able to find any low-level documentation that shows how this approach could work.
Thank you in advance for any advice, pointers, or links.