auth.Validate() == ValidationState.InvalidSignature

Sep 14, 2009 at 2:59 PM

H

I have done a test page but always get auth.Validate() == ValidationState.InvalidSignature

Here's the page code, any suggestions gratefully received:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FBConnectAuth;
using System.Configuration;
using facebook;

namespace FacebookConnect
{
    public partial class paul2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string apiKey = ConfigurationManager.AppSettings["APIKey"];
            string secret = ConfigurationManager.AppSettings["Secret"];

            FBConnectAuthentication auth = new FBConnectAuthentication(apiKey, secret);
            if (auth.Validate() != ValidationState.Valid)
            {
                // The request does not contain the details of a valid Facebook connect session - you'll probably want to throw an error here.
                Response.Write(auth.Validate().ToString());
            }
            else
            {
                FBConnectSession fbSession = auth.GetSession();
                string userId = fbSession.UserID;
                string sessionKey = fbSession.SessionKey;
                // These values can now be used to communicate with Facebook on behalf of your user - perhaps using the Facebook Developer Toolkit
                // The expiry time and session secret is also available.

                API api = new API();

                api.ApplicationKey = apiKey;
                api.SessionKey = fbSession.SessionKey;
                api.Secret = fbSession.SessionSecret;

                long userIDLong = -1;
                long.TryParse(userId, out userIDLong);
                api.uid = userIDLong;

                //Display user data captured from the Facebook API.

                facebook.Schema.user user = api.users.getInfo();
                string fullName = user.first_name + " " + user.last_name;

                lblName.Text = fullName;
            }
        }
    }
}

Cheers

Paul

Coordinator
Sep 14, 2009 at 5:25 PM

Hi Paul,

It looks like you're doing everything correctly. The first thing I would suggest doing is checking the app secret in your web.config vs the value in facebook...

If that doesn't shed any light, you should use a tool like FireCookie to inspect the facebook cookies, and post them here. You could also try creating a new facebook connect app and posting the cookies and the app secret so I can help further...

Thanks,

Adam

On Sep 14, 2009 6:59 AM, "pault70" <notifications@codeplex.com> wrote:

From: pault70

H

I have done a test page but always get auth.Validate() == ValidationState.InvalidSignature

Here's the page code, any suggestions gratefully received:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FBConnectAuth;
using System.Configuration;
using facebook;

namespace FacebookConnect
{
    public partial class paul2 : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string apiKey = ConfigurationManager.AppSettings["APIKey"];
            string secret = ConfigurationManager.AppSettings["Secret"];

            FBConnectAuthentication auth = new FBConnectAuthentication(apiKey, secret);
            if (auth.Validate() != ValidationState.Valid)
            {
                // The request does not contain the details of a valid Facebook connect session - you'll probably want to throw an error here.
                Response.Write(auth.Validate().ToString());
            }
            else
            {
                FBConnectSession fbSession = auth.GetSession();
                string userId = fbSession.UserID;
                string sessionKey = fbSession.SessionKey;
                // These values can now be used to communicate with Facebook on behalf of your user - perhaps using the Facebook Developer Toolkit
                // The expiry time and session secret is also available.

                API api = new API();

                api.ApplicationKey = apiKey;
                api.SessionKey = fbSession.SessionKey;
                api.Secret = fbSession.SessionSecret;

                long userIDLong = -1;
                long.TryParse(userId, out userIDLong);
                api.uid = userIDLong;

                //Display user data captured from the Facebook API.

                facebook.Schema.user user = api.users.getInfo();
                string fullName = user.first_name + " " + user.last_name;

                lblName.Text = fullName;
            }
        }
    }
}

Cheers

Paul

Read the full discussion online.

To add a post to this discussion, reply to this email (fbconnectauth@discussions.codeplex.com)

To start a new discussion for this project, email fbconnectauth@discussions.codeplex.com

You are receiving this email because you subscribed to this discussion on CodePlex. You can unsubscribe or change your settings on codePlex.com.

Please note: Images and attachments will be removed from emails. Any posts to this discussion will also be available online at codeplex.com