Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Facebook API errors with "Session key invalid or no longer valid"

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#?

like image 903
dkarzon Avatar asked Feb 20 '26 16:02

dkarzon


1 Answers

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.

like image 71
Jason Jong Avatar answered Feb 23 '26 04:02

Jason Jong



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!