views:

1002

answers:

1

Doing some work with Facebook connect/the RESTful API and for some reason i keep getting this error

Session key invalid or no longer valid

As far as i can tell im authenticating correctly. Getting the session key from the cookie after the facebook connect dialog pops up and the user logs in. Then i open up the extended permissions dialog to allow posting events and offline access.

But then if the user was to logout of facebook the session key becomes unusable. What am i doing wrong here? Is there any good examples of doing this with ASP.NET/C#?

+1  A: 

I use Facebook Dev Toolkit v3.0 and have mananged to get it to work. Give that a try. My code does this to the client.

Redirect the browser to:

url = @"http://www.facebook.com/login.php?api_key=" + _fbService.Session.ApplicationKey + @"&v=1.0" + @"&next=" + fullReturnUrl + "?";

Then for extended permissions

url = @"http://www.facebook.com/connect/prompt_permissions.php?api_key=" + _fbService.Session.ApplicationKey + @"&v=1.0&next=" + fullReturnUrl + "?xxRESULTTOKENxx" + @"&display=popup&" + @"&ext_perm=offline_access,publish_stream,read_stream" + @"&enable_profile_selector=1";

Once that comes back successfully, its simply a matter of storing the auth_token

string authToken = webContext.Request["auth_token"];

With the extended permissions, I am able to get access even though the person has logged off Facebook.

Jason Jong
hi Jason what code you use to redirect?
Tom
@Tom, which code are you talking about? From Facebook or from the web app?
Jason Jong