Session key invalid or no longer valid error

Jan 2, 2009 at 3:15 AM
hi i've juz recently change to Facebook Developer Toolkit v2.0 and when i was following the simple 'Leveraging the facebook API in 5minutes' in Visual C#.
I've got stuck with the error "Session key invalid or no longer valid"    
 "> FDT_test2.exe!FDT_test2.Form1.Form1_Load(object sender = {FDT_test2.Form1, Text: Form1}, System.EventArgs e = {System.EventArgs}) Line 22 C#"  

the code i've type was juz this

 

private void Form1_Load(object sender, EventArgs e)

 

{

friendList1.Friends = facebookService1.friends.getUserObjects();

}

i dun know what cause the error as i have no problem when i used Facebook Developer Toolkit v1.2 in VS 2005.

Please help.  urgent as i'm doing a project and this is just the 1st step to start.Thanks.

Jan 2, 2009 at 11:24 AM
Can't really tell from what you have got there where your error is coming from, can you post all of your code
Jan 2, 2009 at 10:01 PM
Edited Jan 2, 2009 at 10:03 PM
One thing to check, make sure you have updated your config file with the correct application key etc. I once made an error when I copied the application key to the config file and got this same error.
Jan 5, 2009 at 12:54 AM
hi these are my codes

using

 

System;

 

using

 

System.Collections.Generic;

 

using

 

System.ComponentModel;

 

using

 

System.Data;

 

using

 

System.Drawing;

 

using

 

System.Linq;

 

using

 

System.Text;

 

using

 

System.Windows.Forms;

 

namespace

 

FDT_test2

 

{

 

public partial class Form1 : Form

 

{

 

public Form1()

 

{

InitializeComponent();

}

 

private void Form1_Load(object sender, EventArgs e)

 

{

friendList1.Friends = facebookService1.friends.getUserObjects();

}

}

}

and when i debug they will highlight ' friendList1.Friends = facebookService1.friends.getUserObjects(); ' and said Session key invalid or no longer valid


and yup i'm pretty sure i've got my API and Secret Key correct.

Thanks

Jan 7, 2009 at 1:48 AM
Edited Jan 7, 2009 at 1:49 AM
I'm having the same problem as well.
I followed the guide in documentation.
1. Create new winform application, add the facebook component (facebook.dll and facebook.desktop.dll)
2. Add control FacebookService to the form, set the API key and secret
3. Add control FriendList to the form, set Load event to call Form1_Load
4. Add code in the .cs as followed:
 private void Form1_Load(object sender, EventArgs e)
        {
            friendList1.Friends = facebookService1.friends.getUserObjects();
        }
And I encounter the error "Session key invalid or no longer valid"


Jan 7, 2009 at 1:53 AM
At the risk of being banned...

ME TOO!

Actually, I've had this ever since the new Facebook was released.  I get the feeling it's somewhere deep in the guts of the Toolkit.  I'm using the IFrame Master Page...
Developer
Jan 7, 2009 at 3:06 AM
Please see the discussion here.
Jan 7, 2009 at 4:19 AM
Great news.  Any time frame on when the fix might be included in a release version of the toolkit?
Apr 15, 2009 at 10:48 AM
I was having the same issue, but I got around it by doing (VB code):

FacebookService1.IsDesktopApplication = True

If IsNothing(FacebookService1.SessionKey) Then
    FacebookService1.ConnectToFacebook()
End If

FriendList1.Friends = FacebookService1.API.friends.getUserObjects

ConnectToFacebook will show a login window to open a new session.
Jun 25, 2010 at 10:35 PM
i made all of these..but i still get error... the error is that: Error 1 'Facebook.Rest.Friends' does not contain a definition for 'getUserObjects' and no extension method 'getUserObjects' accepting a first argument of type 'Facebook.Rest.Friends' could be found (are you missing a using directive or an assembly reference?) C:\Users\Mert Aydin\Documents\Visual Studio 2008\Projects\WindowsFormsApplication4\WindowsFormsApplication4\Form1.cs 23 60 WindowsFormsApplication4
Jun 26, 2010 at 5:44 AM

I am now getting tons of exceptions being thrown by the FaceBook Utility response parser. Invalid Session Key is coming up a lot as well. Since I have had a stable app running for over 2 months now, I can conclude that Facebook is changing their response structure...

I am not sure how to address the issues I am seeing now..

 

I am also getting Invalid Parameter exceptions thrown, etc...

Jun 26, 2010 at 6:14 AM
rhapsodus wrote:

I am now getting tons of exceptions being thrown by the FaceBook Utility response parser. Invalid Session Key is coming up a lot as well. Since I have had a stable app running for over 2 months now, I can conclude that Facebook is changing their response structure...

I am not sure how to address the issues I am seeing now..

 

I am also getting Invalid Parameter exceptions thrown, etc...

Am seeing this exact same thing. First time using the FBTK and everything was working superbly until tonight, night of our project launch! Any responses would be great.

 

Jun 26, 2010 at 10:22 AM

I don't know enough about the facebook' back end but the toolkit makes a lot of serialization assumptions, and it will probably be burned for it as 1 parameter gets changed, removed or added. My guess is the facebook xml has changed to accomodate the fields for their new features and the toolkit needs updating

Jun 26, 2010 at 11:28 AM

as A temporary fix I noticed a lot of the Invalid session calls were coming from facebook.users.getInfo... which in this toolkit is in the function GetInfo in Users.cs...

 

When I reduced the information I requested to just a list of simple fields that an app should have access to; even under new facebook rules:

 

        private IList<user> GetInfo(string uids, bool isAsync, GetInfoCallback callback, Object state)
        {
            var parameterList = new Dictionary<string, string> { { "method", "facebook.users.getInfo" } };
            Utilities.AddOptionalParameter(parameterList, "uids", uids);

            Utilities.AddRequiredParameter(parameterList, "fields", "first_name, last_name, name, pic_square");

              //...

 

I noticed the rate of the errors were reduced dramatically. This may not help those who require other fields but for the time being it at least gets users working with my app again... Facebook changed what info an app is allowed to get with a particular session,

 

Jun 27, 2010 at 2:18 AM

Thanks for the heads up. That is the same for me, calls to GetInfo. I found a bunch of articles (older) that referred to this issue being a Facebook issue with it's session ID being expired, yet still issuing them nonetheless.  I'll try limiting my result sets as well and see if that helps.

 

Thanks.