Usage Instructions: Using the Open Graph API

Is this the right set of instructions for you?

If you are using the new Open Graph API Javascript SDK (the src of your javascript will look similar to this page), then this page is for you. If you are using the old style JS libraries, please see Usage Instructions: Using the old Facebook Connect JS libraries.

Overview

First of all, create an instance of FBConnectAuthentication, passing your Facebook Application's Application ID (not the API Key) and Secret, then call the Validate and GetSession methods from within a web request. The authentication and is done automatically using the cookies in the request, and most importantly, the Facebook Connect signature is verified.

Example

You can use Facebook Connect Authentication for ASP.NET by adapting the following example:

FBConnectAuthentication auth = new FBConnectAuthentication(appId,appSecret); //Note this is the "app id", not "api Key"
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.
}
else
{
    FBConnectSession fbSession = auth.GetSession();
    string userId = fbSession.UserID;
    string sessionKey = fbSession.SessionKey;
    string accessToken = fbSession.AccessToken; //This is the Graph API access token (available only when using the Graph API)
    // 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.
}

Last edited Jun 16, 2010 at 9:13 PM by ACreeger, version 5

Comments

headfox Mar 17, 2013 at 9:07 PM 
auth.Validate() is NoSignatureFound... +1 promissing and not working :P

delanthani Aug 8, 2012 at 7:08 PM 
Except the only thing I get on auth.Validate() is NoSignatureFound using my appid and appsecret...so now what.

sparklets Nov 29, 2011 at 3:07 AM 
if (fbSession.Expires == 1) { }
what will be the value of fbSession.connect to validate if session is expired

pcapozzi Jul 5, 2010 at 5:02 PM 
The source files seem to be missing FBConnect.snk.pfx