ASP.NET support for Facebook Connect broken?

Apr 7, 2010 at 12:41 PM

The GetCookie method in ConnectSession tries to pull out the Facebook Connect cookies using the following pattern:

string fullCookieName = string.Format("{0}_{1}", ApplicationKey, cookieName);

However, the cookies seem to be stored in the format "APIKey_cookieName": so GetCookie never finds them and methods such as IsConnected always return false.

Further, one you've hacked your way around that, the CreateHTTPParameterList in RestBase.cs does a similar thing:

parameterList.Add("api_key", Session.ApplicationKey);

which pretty much breaks any REST calls.

 

Is there something obvious that I'm missing here? Because, this just seems fundamentally bust right now.

 

J

Coordinator
Apr 7, 2010 at 2:36 PM

I don't understand your problem.  I just tried the Connect Sample app and it works fine. 

 

Are you passing in your apikey to the constructor.  When I run this it correctly builds the sessionkey cookie name as 9a6e2f9bf3b0be5b695e95d8a6f71f34_session_key for the sample connect app.  Which properly does not find the cookie when not connected and does it find after it is connected. 

You need to make sure you pass in your apikey to the constructor or ConnectSession.

 

_connectSession = new ConnectSession(APPLICATION_KEY, SECRET_KEY);

Apr 7, 2010 at 7:27 PM
Edited Apr 7, 2010 at 7:45 PM

I seem to be having a similar issue.  I have updated the API and Secret Key in the FB Connect Sample and tried to run it on IIS 6 on a NAT'd server (making certain to update Connect URL in the app profile) and I continue to be plagued by errors.  At first, the window would pop-up, I'd login, and it'd simply redirect me back to the screen with the login button.  Now I get directed to localhost:48284.  Any ideas?

 

With the recent changes, I'm trying the latest Facebook.dll, though it doesn't seem to help.

 

Thanks in advance!

 

-Adam

Coordinator
Apr 7, 2010 at 7:38 PM

if you are using the code in the sample.  There is also a javascript init call at the bottom of default.aspx that is passing in the api_key.  So, if you don't change that, it will cause you problems.

Apr 7, 2010 at 7:45 PM

Yea - I changed the Fb.Init call as well.  Not sure what's going on.  Does IIS6 cause any problems?

Coordinator
Apr 7, 2010 at 7:58 PM

well.  if you are running the sample from visual studio.  it is setup to use the visual studio web server at port 48284.  So, that is where that comes from (from you hitting f5 in visual studio).  You can change that in your project properties, if you want it to run in some iis site.

Why the login isn't working is a good question.  The only thing I can say is step into ConnectSession.  To do this, you'll need the source of the facebook.dll.  Remove the reference to the assembly, add an existing project to your solution (add the facebook project).  Then add a project reference in you web app to the newly added project.

Now put a breakpoint in getCookie of ConnectSession.  After login, look to see what the fullCookieName is being set to then look at HttpContext.Current.Request.Cookies and see what cookies are there if any.  Seems like there is some mismatch between the cookie it is expecting to find and the what it is getting back.

The only thing I can think of that would cause that is a mismatch on the api key between the private variable in the Default.aspx.cs and the one in the init function of Default.aspx

Coordinator
Apr 7, 2010 at 7:59 PM

What happens if you run the connect sample without changing anything?

Apr 8, 2010 at 12:39 AM
Edited Apr 8, 2010 at 12:51 AM

I figured it out - I needed to update the Facebook.dll - I was getting the deserialization error... EDIT: I had updated it before, but in the wrong place

 

Thanks so much for walking me through it!

 

-Adam