"Invalid Parameter" Error...

Jul 2, 2007 at 8:22 PM
Edited Jul 2, 2007 at 8:23 PM
I keep getting an "Invalid Parameter" error from the Facebook.Components.FacebookService.CreateSession(authToken) method... I've searched for quite a long time for the solution to this error, but can't seem to find it anywhere (I've tried numerous options)

Here's my code:

Dim s As String, uid As String
_fb = New Facebook.Components.FacebookService

_fb.ApplicationKey = System.Configuration.ConfigurationManager.AppSettings.Get("APIKey")
_fb.Secret = System.Configuration.ConfigurationManager.AppSettings.Get("APISecret")
_fb.IsDesktopApplication = False

s = session("fbsessionkey")
uid = session("fbuserid")

If (Not String.IsNullOrEmpty(s)) Then
_fb.SessionKey = s
_fb.UserId = uid
_success = True
ElseIf String.IsNullOrEmpty(authToken) Then


session("fbsessionkey") = _fb.SessionKey
session("fbuserid") = _fb.UserId
session("fbsessionexpires") = _fb.SessionExpires
_success = True
_success = False
_lastError = "JD001"
_lastErrorMsg = "Not Logged In"
_fb = Nothing
End If

Any ideas?
Jul 2, 2007 at 10:08 PM
Can you post what your application settings are?

I am thinking that maybe your application is not correctly configured as a web application.

Also, where are you getting your auth token? I don't see where that is coming from. You need to get an authToken issued by Facebook. (Which you get by redirecting to the facebook login)
Jul 3, 2007 at 1:05 AM
The only app settings I have are my API Key and Secret, which I've checked 3 times each. (In the code and outside of it, too)

authToken is passed into this function from the Page_Load event of my callback url, as the Response.Querystring("authToken") value...

This line should go above the first line of code in my original post, it's a constructor for my FB class:

Public Sub New(ByVal authToken As String, ByVal session As HttpSessionState)

and it gets called with this:

Dim FB As New FB(Request.QueryString("authToken"), Session)
Jul 3, 2007 at 2:48 PM
Is your application configured as a web application?
Jul 3, 2007 at 4:07 PM
If you mean within Facebook, yes.

If you mean my .net program, it is a web app, but it's hosted on localhost - could that be the problem?

Jul 3, 2007 at 4:14 PM
Nope. Localhost should be fine. Just wanted to make sure that your api key and secret (associated with your developer account) for configured as a web application on facebook.

Is this a standalone web app or a canvas web app?

Can you debug and make sure that you have the correct secret, api and authtoken when you call CreateSession?
Jul 3, 2007 at 4:26 PM
Right now, it's standalone. I think I'd like to make it a canvas app, but I haven't taken the time to learn enough about it. I'm kind of getting into this in shifts.

I have checked the secret, and api key, how can I know if the authToken is correct? I thought it was different every time?
Jul 3, 2007 at 4:48 PM
Just to make sure that none of them are empty or null. Just to make sure that you have correctly read it.

Have you tried to run the webSample project, just to see if it works using my key and secret?
Jul 3, 2007 at 7:14 PM
I figured it out - in the sample I used to start my project, it referenced the authtoken querystring variable as "authToken" not authtoken... So you're right, it wasn't set correctly and passed into the CreateSession function. Oddly enough, my logic in the if .... elseif ... else block wasn't correct either (it was missing a Not in the elseif) so it tried to create session with a null auth token.

Thanks for your help!
Jul 3, 2007 at 8:00 PM
Cool. Glad it works.