--SOLVED-- Winforms ConnectToFacebook - Cancel Button - Failure

Mar 19, 2010 at 12:03 AM
Edited Mar 19, 2010 at 12:19 AM

Hey All,

I just put the finishing touches on a FB Winforms application when I discovered this issue in both my application and the sample application that ships with the toolkit.

After calling ConnectToFacebook, the user is presented with the normal FB login screen.  However if they choose "Cancel", the Facebook HTML disappears and the user is presented with the word "Failure".

I thought it might be my applcation, so I loaded up the sample winforms application FriendViewer, but it does the exact same thing.  I can't put an application into production that simply says "Failure" when they hit the cancel.  I looked at my application settings within FB to ensure it's set as a Desktop Application.

I am using the latest version of the toolkit.  Has anyone else experienced this?  Is there a work around?

Thanks,
Josh

Mar 19, 2010 at 3:21 PM
Edited Mar 19, 2010 at 3:23 PM

Hey All,

I had to go into the FB Toolkit source, but I was able to fix this myself.  The first step was to determine where the "Failure" text was coming from.  It was being rendered when the FacebookWinformBrowser was being redirected to "http://www.facebook.com/connect/login_failure.html".  Once I figured out where this message was originating from, I modified the following function in FacebookWinformBrowser.cs: 

        private void wbFacebookLogin_Navigated(object sender, WebBrowserNavigatedEventArgs e)
        {
            if (e.Url.PathAndQuery.StartsWith("/connect/login_success.html"))
            {
                DialogResult = DialogResult.OK;
                var sessionString = HttpUtility.ParseQueryString(e.Url.Query).Get("session");
                SessionProperties = JSONHelper.ConvertFromJSONAssoicativeArray(sessionString);
            }
            else if (e.Url.PathAndQuery.StartsWith("/connect/login_failure.html")) // JG: This is what I added to the source to fix issue
{ // This will close the window in case of cancel/failure DialogResult = DialogResult.Cancel; } }

Now the window closes, as expected, when the user cancels logging in.  Quite frankly, I was suprised that this wasn't being handled already and begs the question is this release really ready for prime time?

Thanks,
Josh

 

 

Jun 17, 2010 at 2:58 PM

VERY good work.

Jun 17, 2010 at 3:05 PM
Hi Josh, Did you submit the changes or made it locally ? How does one access the DialogResult from within the application to check if user authenticated or cancelled ? Thanks